Quick Start
How It Works
| Component | Role |
|---|---|
| Sandbox | Manages isolation and resource limits |
| Container | Isolated execution environment |
| ResourceLimits | CPU, memory, and time constraints |
| SecurityPolicy | File and network access rules |
Sandbox Types
- Subprocess
- Docker
- E2B
Lightweight isolation using OS-level restrictions.Best for: Quick execution, development, trusted code
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
sandbox_type | str | "subprocess" | Type: subprocess, docker, e2b |
image | str | "python:3.11-slim" | Docker image |
working_dir | str | "/workspace" | Working directory |
auto_cleanup | bool | True | Auto-cleanup after execution |
persist_files | bool | False | Keep files between runs |
Resource Limits
Control resource usage to prevent abuse:| Limit | Minimal | Standard | Generous |
|---|---|---|---|
memory_mb | 128 | 512 | 2048 |
timeout_seconds | 30 | 60 | 300 |
cpu_percent | 50 | 100 | 100 |
network_enabled | ❌ | ❌ | ✅ |
Security Policy
Fine-grained security controls:Result Handling
CLI Commands
Common Patterns
- Code Agent
- Data Analysis
- Batch Execution
Best Practices
Use Docker for untrusted code
Use Docker for untrusted code
Always use Docker sandbox when executing code from untrusted sources. Subprocess isolation is not sufficient for security-critical applications.
Set appropriate resource limits
Set appropriate resource limits
Configure memory and timeout limits based on expected workload. Start with minimal limits and increase as needed.
Disable network by default
Disable network by default
Keep
network_enabled=False unless the code specifically needs network access. This prevents data exfiltration.Review blocked paths and imports
Review blocked paths and imports
Customize
blocked_paths and blocked_imports in SecurityPolicy to prevent access to sensitive system resources.
