Skip to main content
The sandbox feature is experimental and may change in future versions.
The sandbox runs agent commands inside a Docker container while the filesystem tool handles all file I/O on the host. This separation means the agent can execute arbitrary shell commands safely without risking your host system, while file changes flow bidirectionally through bind mounts.

Quick Start

Add sandbox: true and configure filesystem paths:
Docker must be installed and running. The image is pulled automatically if needed.

How Sandbox and Filesystem Work Together

The sandbox only provides command execution. All file access is controlled by the filesystem tool:
  • Filesystem tool reads/writes files on the host — changes appear inside the container instantly via bind mount
  • sandbox__exec runs commands inside the container — if the mount is read-write, file changes flow back to the host
  • Paths are identical in host and container (no /workspace/ alias)

What Gets Mounted

Each filesystem path from your config is mounted at its real host path with the mode derived from its permissions:
Glob patterns (e.g. ${root}/**/*.ts) are skipped — only concrete directories can be mounted. If no filesystem tool is configured, the project root is mounted read-only.
Sandbox refuses to bind-mount $HOME (or any ancestor) as the project root. If a project marker like .git, .agentuse, or package.json exists at $HOME (common for dotfile repos or per-user config dirs), creation fails with a clear error. Run the agent from inside a real project directory, or declare an explicit filesystem mount.

Configuration

Use sandbox: true for defaults (Docker, node:22-slim), or provide a config object:
If any setup command fails (non-zero exit), sandbox creation is aborted.
Common images:
  • node:22-slim — Node.js / TypeScript (default)
  • python:3.12-slim — Python / data science
  • ubuntu:24.04 — General purpose
  • golang:1.23 / rust:1.84-slim — Go / Rust
Need multiple runtimes? Use setup to install them (e.g. apt-get install -y nodejs).

Environment Variables

The container starts with a clean environment — no host env vars are passed in, even if they are defined in your project’s .env file. AgentUse loads .env into the host process, but the sandbox container does not inherit them. To forward specific env vars into the container, use the env allowlist:
Only declared vars that exist on the host are forwarded. Unset vars are silently skipped.

Examples

TypeScript Code Fix

Python Data Processing

Security Scanning (Read-Only)

Lifecycle

  1. Cleanup — Remove any orphaned containers from previous runs (crash/force-quit safe)
  2. Pull — Auto-pull the Docker image if not available locally
  3. Create — Start container with filesystem paths bind-mounted at real host paths
  4. Setup — Run setup commands sequentially inside the container
  5. Execute — Agent uses sandbox__exec for commands, filesystem tool for file I/O
  6. Teardown — Container is stopped and removed when the session ends, times out, or is aborted

Self-Hosting

Need to run AgentUse itself inside Docker? See the self-hosting guide.