langchain-upstash-box package wraps an Upstash Box (a secure, isolated cloud container with a full Linux shell, filesystem, git, and a runtime) as a Deep Agents sandbox backend. The agent’s shell and file tools then run inside the box instead of on your machine.
1. Installation
2. Create a sandbox backend
UpstashBoxSandbox.create() provisions a new box, waits until it is ready, and returns a backend that implements the Deep Agents SandboxBackendProtocol:
The API key and base URL can also be passed directly as
api_key= and base_url= arguments instead of the UPSTASH_BOX_API_KEY and UPSTASH_BOX_BASE_URL environment variables. The base URL defaults to https://us-east-1.box.upstash.com.3. Use with a Deep Agent
Pass the sandbox as the agent’sbackend. Every shell command and file operation the agent performs now runs inside the box:
The
model="anthropic:..." shorthand requires langchain-anthropic (install with pip install "langchain[anthropic]") and an ANTHROPIC_API_KEY environment variable. Any LangChain chat model works here.4. Cleanup
You own the box lifecycle, so callsandbox.delete() when you are done. An idle box pauses automatically: its compute is released but the filesystem is kept, and it wakes up on the next command. The box itself stays around until you delete it.
Commands have a default execution timeout of 30 minutes. You can override it for the whole backend or per call: