Skip to main content

Docker-backed sandbox backend for DeepAgents

Project description

Docker sandbox backend for Deep Agents.

License: MIT Python deepagents

DeepAgents

Run Deep Agents in an isolated Docker container without compromising your host machine.

Quickstart

Requires Docker on your machine.

Install with uv:

uv add deepagents-docker

or with pip:

pip install deepagents-docker
from deepagents import create_deep_agent
from deepagents_docker import DockerSandbox

agent = create_deep_agent(
    model="openai:gpt-5.5",
    backend=DockerSandbox(),
    system_prompt="You are a research assistant.",
)

result = agent.invoke({"messages": "Research the latest trends in AI and write a summary."})

Configuration

Constructor options let you change the image, workspace path, command timeout, resource limits, outbound network access, and any extra docker run flags:

DockerSandbox(
    image="python:3.12-bookworm",      # default image (Debian-based, includes curl, etc.)
    allow_outbound_traffic=True,       # False → no network; True (default) → allow outbound traffic
    workspace_dir="/path/to/project",  # host dir for agent files; see note below
    timeout=120,                       # per-command timeout (seconds)
    max_output_bytes=100_000,          # combined stdout/stderr cap per command
    memory="512m",
    cpus=1.0,
    pids_limit=128,
    auto_remove=True,                  # remove container on close()
    extra_run_args=["--env", "FOO=bar"],
)

[!NOTE] When workspace_dir is omitted, a temporary directory is created under the host temp folder and removed on close() when the sandbox owns it. Pass an explicit path to keep files after the container stops.

How it works

DockerSandbox implements the Deep Agents backend protocol by splitting work across the host and a container:

  • File tools (read, write, edit, grep, glob, ls) run against a workspace directory on your machine.
  • execute runs shell commands in a long-lived Docker container. The same directory is bind-mounted at /workspace, so files stay in sync between tools and commands.

On startup, the sandbox creates a container with conservative defaults:

  • python:3.12-bookworm as the default image
  • Outbound traffic allowed by default
  • No elevated Linux privileges
  • Read-only root filesystem (with small tmpfs mounts for /tmp and /var/tmp)
  • Memory, CPU, and PID limits

[!NOTE] The container is stopped and removed automatically when the Python process exits (atexit). Use a context manager (below) to tear down earlier.

Using a context manager

Use a context manager when you want the container stopped and removed as soon as you leave the block:

from deepagents import create_deep_agent
from deepagents_docker import DockerSandbox

with DockerSandbox() as backend:
    agent = create_deep_agent(model="openai:gpt-5.5", backend=backend)
    agent.invoke({"messages": "..."})

# Container stopped and removed here.
print("Done!")

Development

git clone https://github.com/andybbruno/deepagents-docker.git
cd deepagents-docker
uv sync
uv run pytest

Contributing

Contributions are welcome! Please feel free to open an issue or submit a pull request.

Security

Use this for trusted workloads and development, not as a hard multi-tenant boundary. Do not put secrets in the workspace. See Deep Agents security.

License

MIT — LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepagents_docker-0.0.2.tar.gz (796.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepagents_docker-0.0.2-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file deepagents_docker-0.0.2.tar.gz.

File metadata

  • Download URL: deepagents_docker-0.0.2.tar.gz
  • Upload date:
  • Size: 796.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for deepagents_docker-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4e217a1fd8abf2eeb1023302db7a2f05b011780343509f9f7aabd7fd06a720bb
MD5 1f31838a91de978fb5576ba61763e270
BLAKE2b-256 cfc20fd3b267df414f4b8796c2f8b2213ee85841c7cb56a1ef388b45711c9d77

See more details on using hashes here.

File details

Details for the file deepagents_docker-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for deepagents_docker-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 13161457b651f7ac74af653ef7bff6a0e793fb35671357120e15421cf9d510a7
MD5 6a38fd04c0fb0d89be7ad20a4953b7e9
BLAKE2b-256 ee61179666a3a6eb7b0a55e0e5440deda81989902a476c86df22437cc51c250d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page