Skip to main content
The Pydantic AI logo inside the boxd card. Pydantic AI is the Python agent framework from the team behind Pydantic. Its Harness adds ready-made capabilities, such as 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

The 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

Machines are created and billed in the key’s organization.
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:
If boxd suspended or stopped the machine in between, the next run wakes or starts it again.

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:
The two machines change independently after the fork.

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:
Machines 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 BoxdSandbox creates, and copies fork makes, are isolated: code the agent runs holds no boxd credentials and can’t reach your other machines. BoxdSandbox refuses 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 boxd user.
  • Commands as the boxd user, who has passwordless sudo. A timeout or a cancelled run stops the command’s whole process group.
The Harness docs for BoxdSandbox cover the rest, including durable execution with Temporal, DBOS, and Prefect, the configuration reference, and the security model.