A Docker Sandboxes (
sbx) microVM sandbox backend for Deep Agents — Python & JavaScript.
Give your Deep Agents agent a real machine to work in: every command runs
inside an sbx microVM with its own Linux kernel and a private Docker
daemon — on your laptop (free) or in Docker Cloud Sandboxes (paid). One
pip install / npm install, no Dockerfile, no host pollution.
Deep Agents can run its tools in a sandbox backend. deepagents-sbx is one:
it implements the Deep Agents BaseSandbox protocol on top of
Docker Sandboxes (sbx), Docker's
microVM-based sandbox.
So when your agent writes and runs code, installs packages, or builds containers, it does that inside a disposable microVM — not on your host.
| Stack | Install | Entry point |
|---|---|---|
| Python | pip install deepagents-sbx |
from deepagents_sbx import SbxSandbox |
| JavaScript | npm install deepagents-sbx deepagents |
import { SbxSandbox } from "deepagents-sbx" |
| Deep Agents Code | pip install "deepagents-sbx[code]" |
dcode --sandbox sbx |
| Property | What it gives the agent |
|---|---|
| microVM with its own kernel | A hard isolation boundary — a kernel-level escape in the sandbox doesn't reach your host kernel |
| Private Docker daemon inside the VM | The agent can docker build / docker run (testcontainers, compose, image builds) |
| Network allow/deny policy | Real egress control for arbitrary, LLM-generated code |
| Disposable | Remove it and it's gone — no leftover images, containers or state |
| Free locally | The sbx CLI drives a local microVM; no metered compute (a Docker account is still required to sign in) |
Most Deep Agents sandbox backends (LangSmith, Daytona, Modal, Runloop, Vercel, E2B, plain Docker) are ordinary containers.
deepagents-sbxis the one that runs inside ansbxmicroVM.
Good fit
- You run LLM-generated or otherwise untrusted code and want a hard boundary.
- Your agent needs Docker inside the sandbox (image builds, compose, testcontainers).
- You want egress control — allow PyPI/npm, deny everything else.
- You want reproducible, ephemeral agent runs that don't touch your machine.
- You want local-first (free) with an optional cloud burst for heavier jobs.
Probably not the right tool
- You need GPU compute (reach for a GPU cloud).
- You want a long-lived shared dev box rather than disposable sandboxes.
- You can't install Docker Sandboxes or don't have a Docker account.
Full decision guide: docs/concepts.md.
Requirements: Python 3.12+ (deepagents>=0.7.19) or Node 20+ (deepagents>=1), plus the free sbx CLI.
Prerequisites (once):
- Install the
sbxCLI (it is not apip/npmdependency). macOS:brew trust docker/tap && brew install docker/tap/sbx· Ubuntu 24.04+:curl -fsSL https://get.docker.com | sudo SBX=1 sh· Windows:winget install -h Docker.sbx. See the install docs. Local sandboxes also need hardware virtualization; cloud does not. - Sign in and initialize the local policy:
sbx login
sbx policy init balancedCloud uses the same Docker account and sbx login, but keeps separate
secrets and network policy in cloud stores (sbx --cloud secret set …,
sbx --cloud policy …) and needs an active Docker Agentic Platform subscription. Verify access
with sbx --cloud diagnose, then initialize policy with
sbx --cloud policy init balanced.
Python
pip install "deepagents-sbx[code]" # [code] also registers the dcode providerfrom deepagents import create_deep_agent
from deepagents_sbx import SbxSandbox
with SbxSandbox(memory="4g") as backend: # creates the microVM, removes it on exit
agent = create_deep_agent(model="anthropic:claude-sonnet-4-5", backend=backend)
agent.invoke({"messages": [{"role": "user", "content": "Create a Python CLI and run its tests"}]})JavaScript
npm install deepagents-sbx deepagentsimport { createDeepAgent } from "deepagents";
import { SbxSandbox } from "deepagents-sbx";
const backend = new SbxSandbox({ memory: "4g" }); // created lazily on first use
try {
const agent = createDeepAgent({ model, backend });
await agent.invoke({ messages: [{ role: "user", content: "Run the test suite" }] });
} finally {
await backend.close(); // removes the microVM when autoRemove is set (default)
}Deep Agents Code
dcode --sandbox sbx # local microVM
dcode --sandbox sbx-cloud # Docker Cloud Sandboxes (paid)Same API, cloud=True:
with SbxSandbox(cloud=True, cpus=1, memory="2g", ttl="10m") as backend:
backend.execute("./heavy-job.sh > /home/agent/workspace/out.tar.gz 2>&1", timeout=1800)
artifacts = backend.download_files(["/home/agent/workspace/out.tar.gz"])Cloud sandboxes are billable, have no host bind-mount, and are validated
against billable shapes (micro … xl) before any API call. Always set a
ttl. Details: docs/usage.md § Cloud.
Cloud can also skip the sbx CLI entirely via the opt-in API transport:
from deepagents_sbx import ApiSbxTransport, SbxSandbox
transport = ApiSbxTransport(docker_id="you", personal_access_token="dckr_pat_…")
with SbxSandbox(cloud=True, transport=transport, ttl="10m") as backend:
backend.execute("echo hello")import { ApiSbxTransport, SbxSandbox } from "deepagents-sbx";
// npm install @docker/sandboxes (optional peer, only needed for this transport)
const transport = new ApiSbxTransport({ sdkOptions: { auth: pat({ username, personalAccessToken }) } });
const backend = new SbxSandbox({ cloud: true, ttl: "10m", transport });Auth is independent of sbx login, and both the API and the SDK are
experimental. Details: docs/usage.md § API transport.
There's a runnable end-to-end playground for the cloud path: https://github.com/restuhaqza/deepagents-sbx-playground.
| Doc | What's in it |
|---|---|
| docs/index.md | Map of the docs — start here |
| docs/concepts.md | Mental model, microVM vs container, when (not) to use it |
| docs/use-cases.md | Copy-paste recipes for common scenarios |
| docs/usage.md | API reference: constructor, methods, cloud, errors, troubleshooting |
| docs/spec.md | Implementation spec + verified findings (internal / contributor) |
Package quickstarts (what appears on the registries): Python · JavaScript.
SbxSandbox implements the four members Deep Agents' BaseSandbox needs —
execute(), upload_files(), download_files(), and id. Every other file
operation (read, write, edit, ls, grep, glob, delete) is derived by
the base class and routed through execute().
It talks to Docker Sandboxes through the sbx CLI by default (the only
supported local interface). Cloud uses the same transport: --cloud is a
global flag, so create/exec/cp/rm/ttl share one code path. For cloud you can
instead opt into ApiSbxTransport, which drives the experimental
Sandboxes API with no child
process — a plain REST client in Python, the official @docker/sandboxes SDK
in JS (an optional dependency). Both sit behind the same SbxTransport seam, so
SbxSandbox is unchanged either way. Details:
docs/usage.md § API transport.
More: docs/concepts.md and docs/spec.md.
Alpha (0.1.0), published on
PyPI and
npm. Milestones and the verified
environment matrix live in docs/spec.md.
Contributions are welcome — bug reports, docs, tests, and code. Start with CONTRIBUTING.md for the dev setup and conventions, and see CHANGELOG.md for what changed between releases.
- Report a bug / request a feature: open an issue
- Report a vulnerability: privately via SECURITY.md — please don't open a public issue
This project follows the Contributor Covenant code of conduct.
MIT — see LICENSE.