Overview
AI coding agents like Claude, GPT-4, and others can leverage OpenSandbox to:- Execute code in isolated containers with configurable resource limits
- Install packages and dependencies on-demand
- Access files and directories within the sandbox
- Run development tools (compilers, interpreters, test frameworks)
- Generate and test code safely without affecting host systems
Use Cases
Code Execution for LLMs
Provide language models with a safe execution environment for code generation, testing, and debugging. Benefits:- Isolated execution prevents malicious code from affecting the host
- Ephemeral environments ensure clean state for each task
- Resource limits prevent runaway processes
- Full observability of code execution and outputs
Interactive Development Assistants
Build coding assistants that can write, test, and refactor code in real-time. Example: Claude Code CLI integrationexamples/claude-code/
Agent Workflow Orchestration
Integrate with agent frameworks like LangGraph to create complex workflows that combine LLM reasoning with code execution. Example: LangGraph + OpenSandboxexamples/langgraph/
Key Features
Pre-built Images
OpenSandbox provides optimized images for AI agent use cases:- code-interpreter: Python, Node.js, common development tools
- desktop: Full desktop environment with GUI support
- chrome: Browser automation with DevTools support
SDK Integration
Multiple SDKs for easy integration:- Python SDK with async/await support
- Java/Kotlin SDK for JVM-based agents
- REST API for any language
File Operations
Agents can read, write, and manage files within sandboxes:Resource Control
Configure memory, CPU, and timeout limits per sandbox:Architecture
Security Considerations
Isolation
- Each sandbox runs in a separate container with no network access to other sandboxes
- File system is isolated from the host
- Process isolation prevents privilege escalation
Resource Limits
- Memory and CPU limits prevent resource exhaustion
- Timeout controls prevent infinite loops
- Disk space quotas prevent storage abuse
Authentication
- API key authentication for production deployments
- Optional TLS for encrypted communication
- Audit logging for compliance
Best Practices
1. Use Ephemeral Sandboxes
Create a new sandbox for each task to ensure clean state:2. Set Appropriate Timeouts
Prevent runaway processes with timeouts:3. Handle Errors Gracefully
Check execution results for errors:4. Use Background Processes for Long-Running Tasks
Example Projects
Claude Code CLI
Integrate Anthropic’s Claude with OpenSandbox for interactive coding assistance.- Location:
examples/claude-code/ - Features: NPM package installation, Claude CLI integration, environment variable passing
- Code: View on GitHub
LangGraph Workflow
Build complex agent workflows with state machines and decision nodes.- Location:
examples/langgraph/ - Features: Graph-driven control flow, retry logic, LLM-powered analysis
- Code: View on GitHub
Agent Sandbox
General-purpose agent execution environment.- Location:
examples/agent-sandbox/ - Features: Multi-language support, dependency installation, file I/O
- Code: View on GitHub
Related Resources
Quick Start
Get started with OpenSandbox in 5 minutes
Python SDK
Complete Python SDK reference
Browser Automation
Automate browsers for web agents
API Reference
Full API documentation