
Coder, Shell, and FileSystem, that give an agent tools to run commands and edit files.
BoxdSandbox runs those tools on an isolated boxd machine instead of on your computer. It is part of the Harness, and the boxd team maintains it together with the Pydantic maintainers (pull request).
Set up
1
Install the Harness with the boxd extra
anthropic extra is for the example below; use your model provider’s extra instead. BoxdSandbox ships in the first release after pydantic-ai-harness 0.63.0. Until then, install it from GitHub:2
Create an API key
3
Give the agent a machine
Coder’s shell and file tools now run on the machine. Set ANTHROPIC_API_KEY for the model.Come back to the machine
A follow-up run that gets the first run’s message history works on the same machine, so the clone is still there. To come back later without the history, store the run’s workspace ref and pass it back:Fork a machine
fork(ref) copies a machine into a new isolated one, with its files and running processes as they are at that moment, and returns the copy’s ref. Two agents can then try different approaches from the same starting point at once:
Clean up
Pydantic AI never deletes a machine. boxd suspends, and later hibernates, a machine that sits idle, and you delete one with its ref:BoxdSandbox creates are named pydantic-ai-<hex>, so boxd machine list shows any that a crashed run left behind.
What each machine gets
- Isolation: machines
BoxdSandboxcreates, and copiesforkmakes, are isolated: code the agent runs holds no boxd credentials and can’t reach your other machines.BoxdSandboxrefuses to attach to a machine that isn’t isolated. - The default image: Ubuntu 24.04 with git, Python 3, uv, Node.js, and ripgrep. For your own dependencies, start from a snapshot with
BoxdSandbox(snapshot='my-snapshot'). - A size:
BoxdSandbox(vcpu=4)picks one of boxd’s machine sizes, 1, 2, 4, or 8 vCPUs with 4 GiB each. - Files through boxd’s file API: writes create missing directories, go through symlinks, and keep a file’s mode, all as the machine’s non-root
boxduser. - Commands as the
boxduser, who has passwordlesssudo. A timeout or a cancelled run stops the command’s whole process group.
BoxdSandbox cover the rest, including durable execution with Temporal, DBOS, and Prefect, the configuration reference, and the security model.