Overview
DeerFlow’s sandbox system supports multiple execution modes:Local
Direct execution on the host filesystem
Docker
Isolated containers with AIO Sandbox
Kubernetes
Provisioner-managed pods at scale
Sandbox Interface
All sandbox providers implement the abstractSandbox interface:
Virtual Path System
The sandbox uses virtual paths to isolate threads: Agent View (Virtual):Path Translation
The sandbox translates between virtual and physical paths:Path translation is transparent to the agent. Use virtual paths in prompts and tools.
Local Sandbox
The local sandbox executes directly on the host machine. Configuration (config.yaml):
- Fast execution (no container overhead)
- Direct filesystem access
- Simple debugging
- Local development
- Trusted environments
- CI/CD pipelines
Docker Sandbox (AIO)
The Docker sandbox runs commands in isolated containers via the AIO Sandbox library. Configuration (config.yaml):
- Process isolation
- Resource limits (CPU, memory)
- Network isolation
- Automatic cleanup
- Thread data:
{host_thread_path} → /mnt/user-data - Skills:
{host_skills_path} → /mnt/skills
Docker Setup Guide
Configure Docker sandbox for development
Kubernetes Sandbox (Provisioner)
For production deployments, the Kubernetes sandbox creates pods on-demand via a provisioner service. Configuration (config.yaml):
- Horizontal scaling
- Resource quotas
- Pod security policies
- Persistent storage
Kubernetes Deployment
Deploy DeerFlow with Kubernetes sandboxes
Sandbox Lifecycle
Sandboxes are managed by theSandboxMiddleware:
- Acquire: Get or create sandbox for thread
- Execute: Run commands and file operations
- Release: Return sandbox to pool or destroy
Sandbox Tools
The sandbox provides five core tools:bash - Execute commands
bash - Execute commands
Execute shell commands in the sandbox.Path Translation: Automatic for virtual pathsError Handling: Returns stderr and exit code
ls - List directory
ls - List directory
List directory contents in tree format.Output: Tree format, max 2 levels deep
read_file - Read file
read_file - Read file
Read file contents with optional line range.
write_file - Write file
write_file - Write file
Write or append to files.Auto-creates: Parent directories as needed
str_replace - Replace text
str_replace - Replace text
Replace text in files (single or all occurrences).
Sandbox Tools API
View complete tool reference
Thread Isolation
Each thread has its own isolated filesystem:- No cross-contamination between threads
- Concurrent execution without conflicts
- Easy cleanup (delete thread directory)
Platform Differences
Sandbox behavior varies by platform:- Linux
- macOS
- Windows
- Docker socket:
/var/run/docker.sock - Native path mounting
- Best performance
Best Practices
Use virtual paths in agent prompts
Use virtual paths in agent prompts
Always reference Not:
/mnt/user-data/ and /mnt/skills/ in prompts:backend/.deer-flow/threads/abc123/user-data/uploads/data.csvStore outputs in /mnt/user-data/outputs
Store outputs in /mnt/user-data/outputs
User-facing files should go in the outputs directory:Then present with
present_files(["/mnt/user-data/outputs/report.html"])Clean up temporary files
Clean up temporary files
Remove temporary files in workspace after use:
Handle errors gracefully
Handle errors gracefully
Check command exit codes:
Next Steps
Sandbox Configuration
Configure sandbox providers
Sandbox Tools
Tool API reference
Docker Setup
Set up Docker sandbox
Kubernetes
Deploy with K8s sandboxes