
BoxdSandbox makes that sandbox a boxd machine. It comes from boxd-langchain, a package the boxd team maintains, and LangChain lists it with its sandbox integrations (pull request). Deep Agents compiles to a LangGraph graph, so the same backend works from LangChain, LangGraph, and Deep Agents.
Set up
1
Install the package
langchain-anthropic is for the example below; use your model provider’s package instead.2
Create an API key
3
Give the agent a machine
ANTHROPIC_API_KEY for the model. The agent’s shell and file tools now run on the machine, and leaving the with block deletes it.Come back to a machine
To keep the agent’s work, create the machine yourself and hand its id toBoxdSandbox. A backend made from an existing machine never deletes it.
Fork a machine
A fork copies a machine into a new one, with its files and running processes as they are at that moment. Set a project up once, fork it, and give each agent its own copy:backend.client is the plain boxd Python SDK client, so snapshots, egress allowlists, and everything else boxd offers are one call away. The package’s parallel_forks.py example runs two agents on two forks at once.
Deep Agents Code
The package also registers boxd as a sandbox for Deep Agents Code, LangChain’s terminal coding agent:dcode deletes it on a clean exit, and BOXD_DELETE_AFTER has boxd delete it after that many seconds if a run ends early. To pick a machine up again, pass its id or name, and dcode wakes it if it is asleep:
What each machine gets
- Isolation when you ask for it:
isolated=Truecreates the machine with no boxd credentials and no route to your organization’s other machines. Use it whenever a model writes the code that runs. - A deadline:
delete_aftersets a delete-after timer, so boxd deletes the machine even if your process dies before thewithblock ends. - The default image: Ubuntu 24.04 with Python 3, git, Node.js, Docker, and ripgrep. For your own dependencies, start from a snapshot with
BoxdSandbox.create(from_snapshot="my-snapshot"). - Commands as the
boxduser, who has passwordlesssudo, in/home/boxd. A command’s output is its stdout and stderr, and its exit code comes back unchanged. - A timeout: a command that runs past its timeout, 30 minutes by default, is stopped with its whole process group and returns exit code 124.
Read more
boxd-langchainon GitHub: options, errors, limits, and three examplesboxd-langchainon PyPI- Sandbox integrations in LangChain’s docs
- Sandboxes on boxd