Skip to content

Deep Agents + OpenSandbox Example

Run a Deep Agent whose file and shell tools execute inside an OpenSandbox sandbox. The langchain-sandbox-opensandbox backend adapts the OpenSandbox Python SDK to the Deep Agents BaseSandbox interface, so every ls / read_file / write_file / glob / grep / command the agent performs is sandboxed.

The backend passes the full langchain-tests SandboxIntegrationTests conformance suite (86/86) against a live server.

Start OpenSandbox server [local]

Start a local OpenSandbox server, logs will be visible in the terminal:

shell
uv pip install opensandbox-server
opensandbox-server init-config ~/.sandbox.toml --example docker
opensandbox-server

Run the example

shell
# Install Deep Agents + the OpenSandbox backend
uv pip install deepagents langchain-sandbox-opensandbox

# Run the example (requires SANDBOX_DOMAIN / ANTHROPIC_API_KEY)
uv run python examples/deep-agents/main.py

The agent writes a Python script into the sandbox, runs it, and reports the output — all file and shell operations happen inside the sandbox rather than on the host. The sandbox is destroyed on exit (terminated and local resources closed).

Environment Variables

VariableDefaultDescription
SANDBOX_DOMAINlocalhost:8080Sandbox service address (host and optional port)
SANDBOX_PROTOCOLhttpProtocol used to reach the server (http or https)
SANDBOX_API_KEY(optional for local)API key if your server requires authentication
ANTHROPIC_API_KEY(required)Anthropic API key for the default Deep Agents model

References

Released under the Apache 2.0 License.