Skip to content

Features

A tour of what fastsandbox provides, in the order you meet it. Each table links to the pages of the documentation that show it in use.

Sandboxes

Capability Details
Connection connect() finds the socket of sbx, checks the health of the daemon and its API version; deadlines per request and for long operations.
Life cycle Create from a kit, with progress; look up, inspect, start, stop, delete; async with deletes on exit; save as a template.
Sessions A sandbox runs while a session is held: async with sandbox.running().
Commands exec to completion with exit code and both outputs, check, users, working directory, environment, standard input, deadlines.
Files Single files, whole directories in both directions, tar archives.
Interactive sessions A shell or the agent of the kit, with standard input, an output stream, a terminal and its size.
Ports Publish a port of the sandbox on the host, from the start or on a running sandbox.

Sandboxes · Commands · Files · Interactive sessions · Ports

Network and credentials

Capability Details
Rules of one sandbox Allow and deny hosts for one sandbox; the rules go with it. Hosts are checked as the sbx CLI checks them, before anything is sent.
Global policy Rules, checks of a host against the policy, the activity log, profiles.
Secrets Custom secrets and credentials of services, pushed to one sandbox and injected by its proxy; the credentials the daemon withholds, named at creation and on each push.
Proxied keys An API key of the program, written by the proxy in place of the placeholder the sandbox holds, in the requests to its hosts only, whatever the daemon authorizes; its value never comes back to Python. The sandbox can still use it, through the placeholder, while it lives.

Network and policy · Credentials

Sandbox specs

Capability Details
A sandbox as data SandboxSpec holds all a sandbox receives but its name and the values of its keys: its kit and mixins, workspace and mounts, host and HTTP rules, API keys, MCP servers, variables and resources; its JSON form serves a program in another language.
Checks The spec checked against the rules of a launch and the kit policy of the daemon, and its keys against their values, before anything is created.
Launch One call forges the kit, creates the sandbox, applies its rules, pushes its keys and starts it; the Lease it returns owns the sandbox until it is shut down, and its Report says what the launch did, never the value of a key.

Sandbox specs

The daemon and its services

Capability Details
Images List, inspect, pull with progress, load, export to a file or as a stream of chunks (export_stream), remove.
Events and prompts The event stream and the approval prompts, as typed async streams.
SSH A byte tunnel to the SSH server of a sandbox, and fastsandbox ssh-proxy for the SSH client of the system.
MCP gateway The gateway mode, the gateway of a sandbox, servers loaded and unloaded.
Daemon Health, settings, log levels, disk usage, diagnostics, the resources of a sandbox.
Kits Kits named as sbx create names them; packages forged without the sbx CLI, or compiled by it when asked, and kept in memory or in a directory, reused while they suit the daemon and made again when a mixin changes; mixins forged over a compiled or saved package (KitForge.forge_over, forge_over_base); packages assembled by hand, a creation request and its images held in memory (KitPackage.in_memory); mixins read from their directories or written in Python, MCP servers of three kinds for claude, copilot and opencode included, their arguments checked; kits added to a running sandbox.
Errors One hierarchy under SandboxError, a class per kind of failure, typed attributes.

Images · Events and prompts · SSH · MCP gateway · The daemon · Kits · Errors

Tasks

Capability Details
Declaration @app.task states the kit, the network rules, the deadline ("10m"), the environment, the CPUs and the memory of the sandbox of each run, which is launched from the spec they describe.
Validation The parameters are the inputs, validated before the sandbox is created; the return annotation validates the result.
Host paths A directory of the host as the workspace, a private Git clone of it, more mounts, or a copy of its contents.
Injection Context, Sandbox, Client and AgentRunner by annotation; Depends, generators included.
Lifespan and state What runs around the application, and the state it shares with its runs.
Running await app.run(...), app.run_sync(...), fastsandbox.run(...), several runs at once, progress.
Command line fastsandbox tasks and fastsandbox run, the inputs as options; info, kits compile, ssh-proxy.

Tasks · Inputs and outputs · Host paths · Dependencies · Lifespan and state · Running tasks · Command line

Agents

Capability Details
The agents of sbx Claude Code, Codex, Copilot, Cursor, Devin, Docker Agent, Droid, Kiro and OpenCode, by the name of their kit, with the profiles of docker-sandbox-kit: the keys each takes and how it runs one prompt without a terminal.
Credentials Read from the environment of the host, as the profile of the agent names them, and given to the proxy of the sandbox of the run only: the sandbox holds a placeholder.
Running modes Unattended (ctx.agent.prompt), streamed step by step (ctx.agent.stream), or interactive (ctx.agent.session).
Network The kit of the agent declares the hosts it needs; the host rules of the task apply from the creation of the sandbox, its HTTP rules before its start; both add to the global policy of the daemon.
Tools MCP servers registered in Claude Code, Copilot or OpenCode by the task (mcp=[...]): a server of the host, whose token is drawn for each run, a remote one, or a program started in the sandbox; or servers loaded into the MCP gateway of its sandbox.

Quickstart · Agents · Working with repositories · Restrict network access · Stream agent events · Connect MCP tools · Run agents concurrently

Testing

Capability Details
Fake daemon FakeDaemon serves the socket API in memory and records what a run did.
Fake kits The published kits shell and claude, served for the forge; fake_package() writes kit packages that need neither the sbx CLI nor an image.

Testing