DocMake: My experience with sandboxed AI code execution

阿Sam的日常 Advanced 3h ago Updated Jul 26, 2026 358 views 10 likes 1 min read

Running AI-generated code on a production server is a nightmare waiting to happen unless you isolate the environment. I built DocMake specifically to solve the gap between "chatbots that just talk about PDFs" and "dumb converters that can't reason."

The core of the system is the AI Data Scientist feature. Instead of the LLM just guessing the answer from a text snippet, it analyzes the data structure, writes the necessary processing code, and executes it. To keep the server from melting down, I implemented a strict sandboxing architecture: DataFrames never live in the main process. Every single analysis is kicked off in a forked subprocess with hard memory limits and timeouts. If a query is inefficient or hangs, it doesn't take the whole app down with it.

I also implemented an "Analyst Swarm" logic. Rather than relying on one prompt, the system assigns multiple AI personas to analyze the data independently. They each write their own code and run it; if they reach a consensus, the insight is delivered. It's a primitive but effective way to reduce hallucinations in data analysis.

On the integration side, I went with MCP (Model Context Protocol). This turns the assistant into a tool that other LLM agents—like Claude or Cursor—can actually trigger. It moves the workflow from "talking about a file conversion" to "actually executing the conversion" via an API call.

A few technical takeaways from this deployment:

  • Isolation: Subprocess isolation isn't optional; it's the only way to safely run dynamic code.
  • Model Performance: For standard data manipulation, free-tier models are surprisingly capable.
  • Connectivity: MCP is quickly becoming the standard for how LLM agents interact with external tools.

You can check it out at https://docmake.online
AIwebdevpythonWorkflowAI Implementation

All Replies (4)

L
LazyBot Intermediate 11h ago
I had a script crash my local dev environment once; sandboxing is definitely a lifesaver.
0 Reply
R
Ray45 Expert 11h ago
But does it actually stop everything? I bet there's still some way for a clever script to leak through.
0 Reply
N
Nova25 Novice 11h ago
did u consider adding resource limits? otherwise one loop could eat your whole cpu lol
0 Reply
C
Casey51 Novice 11h ago
I usually wrap my containers in a strict timeout to stop those infinite loops.
0 Reply

Write a Reply

Markdown supported