fastsandbox
Run code and coding agents in throw-away Docker Sandboxes, from Python.
fastsandbox lets a Python program hand work to Docker Sandboxes: a test suite to run on a copy of a repository, an issue for a coding agent to fix, a tool to try out. It gets back a typed result, and the sandbox is gone.
Documentation · Quickstart · API reference · Examples · docker-sandbox, the Rust crate underneath
fastsandbox is an independent, community-maintained project. It is not affiliated with, sponsored or endorsed by Docker, Inc., and uses the Docker name only to say which product it is made for.
Docker Sandboxes, in a few words
Docker Sandboxes runs code, and coding
agents, in throw-away microVMs on your machine. Each sandbox has its own
system, its own files and its own network policy. Its proxy decides which
hosts it reaches and adds the credentials of a service to the requests sent to
it, so a secret never has to be inside the sandbox. A sandbox is created from a
kit, which says what it holds: a plain shell, or a coding agent such as Claude
Code or Codex, ready to work. All of it is driven by the sbx CLI, which talks
to a daemon, sandboxd, through a socket.
For anyone who runs coding agents, this changes what is safe. An agent can edit files and run commands without asking, because the worst it can break is a machine thrown away after the run. It can work on a clone of your repository rather than the repository itself, and reach only the hosts you allowed.
The goal of this stack
Without a library, a Python program that wants a sandbox runs the CLI and parses what it prints. fastsandbox talks to the socket of the daemon instead.
It is built on docker-sandbox,
a Rust crate by the same author that does all the work with the daemon. The
crate is the client of the socket: it maps the API of the daemon version by
version, and checks the version of the daemon when it connects. fastsandbox
brings it to Python through a native extension, and adds two layers: a typed
async client that reaches every route of the daemon, and FastSandbox,
where the work done in a sandbox is a typed function under a decorator.
What that buys you, in practice:
- Work declared, not scripted.
@app.taskand@app.agentput the kit, the network rules, the deadline and the credentials of a sandbox next to the function that uses it. The signature of the function validates its inputs and its result. - Every agent
sbxknows, one way. Claude Code, Codex, Copilot, Cursor, Devin, Docker Agent, Droid, Kiro and OpenCode are all run the same way: one prompt run unattended, a stream of what the agent reports as it goes, or an interactive session. - Keys that stay outside. The API key of an agent is read from your environment and pushed to the sandbox of the run only. Its proxy adds the key to the requests the agent sends to its service; the agent only sees a placeholder.
- Your repository untouched. On a private clone, the agent may change and commit anything. Its work comes back as a patch to review, and your directory stays as it was.
- Sandboxes that clean up after themselves. The sandbox of a run is deleted when the run ends, also on an error, a timeout or Ctrl-C.
- Errors you can act on. A missing sandbox, a deadline or a failed command each raise their own error class, with typed details, not a message to parse.
- Tests without a daemon. A fake daemon serves the socket API in memory, so the code that drives sandboxes is tested in any CI.
Where it fits
- Coding agents on your repositories: a fix, a review, a patch from a private clone, or several agents on one issue with the tests choosing the patch that holds.
- Checks in a throw-away machine: a test suite, a build or a linter on a copy of a repository, with access to the hosts it needs and no others.
- Code you would rather not run on your machine: run it in a sandbox instead, then read its output and the hosts it tried to reach.
- Agents with tools: the MCP servers an agent needs, given through the gateway of its sandbox.
- Tooling around the daemon: a watcher on its events, an audit of the network policy, a cleanup of old sandboxes and images.
Getting started
Install Docker Sandboxes first, its daemon running for your user: fastsandbox connects to its socket and does nothing without it. Then, with Python 3.12 or newer:
uv add fastsandbox # or: pip install fastsandbox
fastsandbox info # finds the daemon and checks its API version
An agent task: Claude Code explains a project, working on a private clone of it.
from pathlib import Path
from typing import Annotated
from fastsandbox import Context, FastSandbox, WorkspaceDir
app = FastSandbox("quickstart")
@app.agent("claude", timeout="15m")
async def explain(ctx: Context, repo: Annotated[Path, WorkspaceDir(clone=True)]) -> str:
"""Has Claude Code explain a project, working on a private clone of it."""
workdir = str(repo.resolve())
await ctx.agent.prompt(
"Explain what this project does and how its code is laid out, "
"in twenty lines at most, and write the explanation to EXPLAINED.md.",
working_dir=workdir,
)
# The file is in the clone, inside the sandbox: the host is untouched.
return await ctx.sandbox.read_text(f"{workdir}/EXPLAINED.md")
fastsandbox kits compile claude # once: the first compilation takes a few minutes
export ANTHROPIC_API_KEY=sk-ant-...
fastsandbox run agent.py explain --repo .
The quickstart explains this task line by line. From there, the documentation covers what a real setup needs: an agent's repository, its network, following its work, giving it tools, then tasks, the client and testing.
With Claude Code
The repository is also a marketplace of Claude Code plugins. Its plugin teaches Claude the whole library and adds commands that set up a project, check the machine and add tasks:
/plugin install fastsandbox --marketplace aartintelligent/fastsandbox
See With Claude Code.
Status
fastsandbox is in alpha. Version 0.1 covers:
- the whole socket API of the daemon;
- tasks and agent tasks, with the nine agents of
sbx; - the MCP gateway;
- the fake daemon for tests.
It runs on Linux and macOS, where Docker Sandboxes runs.
The socket API of Docker Sandboxes is private and changes with sbx releases.
Each release of fastsandbox is checked against a range of API versions, and
connecting to a daemon outside that range fails unless you allow it. The API
of fastsandbox itself may still change before 1.0. Such changes are listed in
the changelog.
FAQ
Is this an official Docker project? No. fastsandbox is independent and community-maintained. Docker Sandboxes, its licence and its roadmap belong to Docker, Inc.
Do I need Docker Sandboxes installed? Yes. fastsandbox is a client of its
daemon and connects to the sandboxd socket. The sbx CLI must be on PATH
too: it compiles a kit the first time a sandbox uses it.
Can it drive the Docker Engine, containers and images? No. It works only with Docker Sandboxes; containers and images outside it are the job of the Docker SDK.
Does my API key enter the sandbox? No, for every agent but Kiro. The key is
pushed as a secret of the sandbox of the run, and the proxy adds it to the
requests the agent sends to its service. Kiro has no such secret in sbx, so
its key is passed to the agent process as an environment variable, and is
visible inside the sandbox.
Is it safe to let an agent run unattended? The isolation is that of Docker
Sandboxes; fastsandbox decides what crosses it: which directory, which hosts,
which credentials. The default network policy of sbx may allow everything,
so give an unattended agent network rules. Then check its work with the tests
of the project rather than trusting what it reports. The
security guide
goes through each point.
Can I test my code without a daemon? Yes. fastsandbox.testing serves the
socket API from memory: no sbx, no image, no microVM.
Is it production ready? It is 0.1. Every change runs the following
checks:
- the tests on Linux, and on macOS when the package changes;
- mypy in strict mode;
- a coverage threshold;
- the build of the documentation;
- an audit of the Rust and Python dependencies.
The socket API it relies on is private, though: read the status above before building a product on it.
How is it organised? A Python package over
docker-sandbox, the Rust
client of the socket, joined by a thin native extension. Everything about the
daemon is in the crate: a new route or field of the daemon goes into it
first, then into fastsandbox. Every helper and every default is Python. The
design page
records the layers and the decisions behind them.
Contributing
See CONTRIBUTING.md: setting up, the checks, commits and pull requests. To report a vulnerability, see the security policy.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
Metadata
Release files for fastsandbox 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastsandbox-0.1.3.tar.gz | 88.6 kB | With provenance | Details for fastsandbox-0.1.3.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| fastsandbox-0.1.3-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ x86-64 | Details for fastsandbox-0.1.3-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
| fastsandbox-0.1.3-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl | CPython 3.12 | abi3 | Linux glibc 2.17+ ARM64 | Details for fastsandbox-0.1.3-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
| fastsandbox-0.1.3-cp312-abi3-macosx_11_0_arm64.whl | CPython 3.12 | abi3 | macOS 11.0+ ARM64 | Details for fastsandbox-0.1.3-cp312-abi3-macosx_11_0_arm64.whl |
| fastsandbox-0.1.3-cp312-abi3-macosx_10_12_x86_64.whl | CPython 3.12 | abi3 | macOS 10.12+ x86-64 | Details for fastsandbox-0.1.3-cp312-abi3-macosx_10_12_x86_64.whl |
Total release size: 8.1 MB
Release files / fastsandbox-0.1.3.tar.gz
| Download URL | fastsandbox-0.1.3.tar.gz |
|---|---|
| Size | 88.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9753a55146c6df027cf19127b836cafb294bfb8f81502a1a81a8d9ec7facb103
|
|
BLAKE2b-256 checksum How to use checksums |
c66b4485b936c89146bb4230af3cc4e75e0faa3fff7f4f7c263429fa32e50f41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / fastsandbox-0.1.3-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | fastsandbox-0.1.3-cp312-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 2.1 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
7d704d2a2b4a3d6644a4cb521fd57866048155ae33714bddef9d3a2ad27a6690
|
|
BLAKE2b-256 checksum How to use checksums |
484e6e67e6bf63b40634bf99be8251b8fd139795b5097b0f9a34bf550b0fd4b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / fastsandbox-0.1.3-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
| Download URL | fastsandbox-0.1.3-cp312-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
02fa7e9bf6291f8501412067b9747e7cec2ab8f497ff7585c8dd8c5e64807971
|
|
BLAKE2b-256 checksum How to use checksums |
8443200617a88f4fda8226b460fc7384843ea142a57a25b7b892467a3d1c0787
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / fastsandbox-0.1.3-cp312-abi3-macosx_11_0_arm64.whl
| Download URL | fastsandbox-0.1.3-cp312-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 1.9 MB |
| Tags | CPython 3.12 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f7c55c2610298b9d7eb9ea17578d1070ec07287f30deb5462db4bdd27683568d
|
|
BLAKE2b-256 checksum How to use checksums |
469e42b3e3ce2b31ebb4d8a899aba3506db6b4a38590eae932f640262be5df7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logRelease files / fastsandbox-0.1.3-cp312-abi3-macosx_10_12_x86_64.whl
| Download URL | fastsandbox-0.1.3-cp312-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.12 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
078de3505467f28a058aeeaa195a620d817a007aaf83b9eb92c0455f4b13ef80
|
|
BLAKE2b-256 checksum How to use checksums |
2674c0cbdedf70e9ec1da61f6eac4f2a74b86f350de4968fc27c32d30ce864b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logSecurity for fastsandbox 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 5 files in this release have been uploaded with provenance metadata.
Attestation for fastsandbox-0.1.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.