Overview
Sandboxes are containerized Linux environments that provide agents with their own isolated computer to execute tasks, access the web, and manipulate files. Each sandbox is a full-featured development environment with pre-installed tools and services.Sandbox Architecture
Technology Stack
Sandboxes are powered by Daytona, which provides:- Docker containers: Isolated execution environments
- Resource management: CPU, memory, and disk allocation
- Lifecycle management: Start, stop, archive, and delete
- Network access: Public endpoints for web servers
backend/core/sandbox/sandbox.py:11-32
Included Services
Each sandbox includes:- Chrome browser: For web interactions and automation
- VNC server: Remote desktop access for visual tasks
- Web server: Serves content on port 8080 from
/workspace - Supervisord: Process management for background services
- Full sudo access: Complete system control
backend/core/sandbox/README.md:6-12
Sandbox Lifecycle
1. Creation
Sandboxes are created from snapshots with pre-configured services:backend/core/sandbox/sandbox.py:82-127
2. Active State
When a sandbox is active, agents can:- Execute shell commands
- Read and write files
- Run web servers
- Access the internet
- Use Chrome for web automation
- Display visual content via VNC
3. Stopped State
Sandboxes automatically stop after 15 minutes of inactivity:- Container is paused
- State is preserved
- Can be quickly restarted
- No compute costs while stopped
4. Archived State
Sandboxes are archived after 30 minutes in stopped state:- Full state snapshot taken
- Minimal storage cost
- Can be restored when needed
- Longer startup time (restoring from archive)
5. Deletion
Sandboxes can be permanently deleted:backend/core/sandbox/sandbox.py:129-144
Getting or Starting Sandboxes
The platform automatically manages sandbox state:backend/core/sandbox/sandbox.py:34-66
Supervisord Management
Supervisord manages background services in the sandbox:backend/core/sandbox/sandbox.py:68-80
Sandbox States
Daytona manages sandboxes through several states:Project-Sandbox Relationship
Each project can have one sandbox:- Persistent file storage across conversations
- Shared environment state
- Long-running services
- Collaborative workspace
Sandbox Configuration
Environment Variables
Sandboxes are configured with environment variables:backend/core/sandbox/sandbox.py:97-109
Resource Limits
Sandboxes can be configured with resource limits:backend/core/sandbox/sandbox.py:110-114
Auto-Stop and Archive
Sandboxes automatically manage their lifecycle:backend/core/sandbox/sandbox.py:115-116
Sandbox Tools
Agents interact with sandboxes through specialized tools:Shell Tool
Execute commands in the sandbox:Files Tool
Manage files and directories:File Reader Tool
Read file contents:Other Sandbox Tools
- Vision Tool: Analyze images and screenshots
- Image Edit Tool: Manipulate images
- Presentation Tool: Create and edit presentations
- Spreadsheet Tool: Work with spreadsheets
- Git Sync Tool: Version control operations
- Upload Tool: Upload files to sandbox
- Expose Tool: Create public URLs for services
- Knowledge Base Tool: Access project knowledge
backend/core/tools/tool_registry.py:11-24
Customizing Sandboxes
You can customize the sandbox environment for your needs:1. Modify Docker Image
Edit files in thedocker/ directory:
2. Build Custom Image
3. Create Daytona Snapshot
Create a new snapshot in Daytona with your custom image.4. Update Configuration
Update the snapshot name in:backend/core/sandbox/sandbox.pybackend/utils/config.py- Daytona deployment configuration
backend/core/sandbox/README.md:14-47
Sandbox API
The sandbox API provides comprehensive control:Sandbox Operations
- Create:
daytona.create(params) - Get:
daytona.get(sandbox_id) - Start:
daytona.start(sandbox) - Stop:
daytona.stop(sandbox) - Delete:
daytona.delete(sandbox)
Process Management
- Create session:
sandbox.process.create_session(session_id) - Execute command:
sandbox.process.execute_session_command(session_id, request) - Stream output: Real-time command output
File Operations
- Read file:
sandbox.fs.read_file(path) - Write file:
sandbox.fs.write_file(path, content) - List directory:
sandbox.fs.list_dir(path)
backend/core/sandbox/api.py
Web Server Access
Sandboxes include a web server on port 8080:- Serves files from
/workspacedirectory - Publicly accessible when sandbox is running
- Useful for hosting web apps, APIs, and static sites
Example: Serving HTML
backend/core/sandbox/README.md:10
Performance Considerations
Cold Start Time
Sandbox state affects startup time:- Already running: Instant (0ms)
- Stopped: Fast (~1-3 seconds)
- Archived: Slower (~10-30 seconds)
Cost Optimization
The auto-stop and auto-archive intervals optimize costs:- Active use: Full compute cost
- After 15min inactive: Stops (no compute cost)
- After 30min stopped: Archives (minimal storage cost)
Session Management
Supervisord sessions persist background processes:- Database servers
- Development servers
- Background workers
- System services
Security
Isolation
Each sandbox is fully isolated:- Separate containers
- Network isolation (configurable)
- File system isolation
- Resource limits
Access Control
Sandboxes are tied to projects:- Only project owner can access
- VNC password protected
- API key authentication required
Related Concepts
Tools
Learn about sandbox tools that agents use
Agents
Understand how agents execute in sandboxes
Threads
See how threads relate to sandboxes
Projects
Explore project management