Table of Contents
- What Claude Managed Agents self-hosted sandboxes change
- When a self-hosted sandbox is worth it
- How the worker and the queue fit together
- What it costs: Anthropic's meter plus your machine
- Two ways to run it on Agent37
- One always-on worker
- One sandbox per session
- Four problems we hit building it
- FAQ
- Does a self-hosted sandbox lower the Claude Managed Agents bill?
- Does my data stay off Anthropic's servers?
- Can one worker run several sessions at once?
- Which sandbox providers work?
- Can the agent run Docker?
- Run your first self-hosted session
self_hosted environment, run Anthropic's worker on your machine, and each session waits in a queue until your worker claims it. On Agent37, that machine is a sandbox that costs $4.76 a month left on around the clock, or cents a month when it sleeps between turns.What Claude Managed Agents self-hosted sandboxes change
ã…¤ | Cloud environment | Self-hosted sandbox |
Where commands run | Anthropic's container | Your worker |
Files and processes | On Anthropic's side | Stay on your worker |
Still sent to Anthropic | Conversation, tool results, files, skills, memory | Conversation, tool results, skills, memory |
Network rules | Set on the environment | Your own policy |
Installed software | A preinstalled set plus what you add | Whatever your image has |
What you operate | Nothing | The host, its hardening, the environment key |
When a self-hosted sandbox is worth it
- The data can't leave your network. Source code, customer files, or a database dump stay on the worker. Only what a command prints goes back.
- The agent needs internal services. Commands run inside your network, so the agent can reach a private API or package registry.
- You want your own toolchain. Compilers, CLIs, and internal packages live in the image instead of being installed at the start of every session.
- The work should persist. A cloned repo and its installed dependencies can still be there next week.
- The job needs a different machine. More cores, more memory, or a full VM that runs Docker.
file or github_repository resources into a self-hosted session (the request fails with a 400), vault environment-variable credentials don't apply, and the sandbox has only what your image installs.How the worker and the queue fit together
self_hosted environment is a work queue. Setup takes four steps.- Create the environment. In the Claude Console choose Environments, then Create environment, then Self-hosted. Or use the API:
curl https://api.anthropic.com/v1/environments \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "anthropic-beta: managed-agents-2026-04-01" \
-H "content-type: application/json" \
-d '{"name": "agent37", "config": {"type": "self_hosted"}}'- Generate an environment key. Open the environment in the Console and click Generate environment key. This step is Console-only, even for an environment you created through the API. The worker signs in with this key. A regular Claude API key in its place fails with
401 Invalid bearer token.
- Start the worker on a Linux host with
/bin/bashand outbound HTTPS. It needs no open port and no public URL:
export ANTHROPIC_ENVIRONMENT_ID="env_..."
export ANTHROPIC_ENVIRONMENT_KEY="sk-ant-oat01-..."
ant beta:worker poll --workdir /workspace- Create sessions that target the environment. Each one waits until a worker claims it. To confirm the worker is connected, call
GET /v1/environments/{id}/work/statsand check thatworkers_pollingis at least 1.
ant worker serves one session at a time and holds it for a minute after each turn, so a quick follow-up skips the queue. To run sessions in parallel, start more workers on the same environment. They all poll one queue, and each session goes to the first free worker.What it costs: Anthropic's meter plus your machine
Setup | What it does | Agent37 cost |
One always-on worker | Serves sessions one at a time, never sleeps | $4.76 a month |
One sandbox per session | Agent works about 10 minutes a day, sleeps the rest | About $0.40 a month per session |
A sleeping sandbox | Keeps the session's files, uses no compute | About $0.36 a month for 4 GB |
Full VM, always on | Its own kernel, runs Docker | $11.36 a month |
Two ways to run it on Agent37
One always-on worker
ant CLI as its main process, publish it as a template, and create one sandbox with the environment ID and key in its env. The worker starts polling within seconds. Our setup guide has the Dockerfile and every command.One sandbox per session
WorkPoller. For each session it claims, it finds that session's sandbox or creates one with auto-sleep on. Then it starts ant beta:worker run through Agent37's exec API, which wakes a sleeping sandbox first.npm install
cp .env.example .env # fill in the four keys
node create-agent.mjs # prints AGENT_ID, add it to .env
node orchestrator.mjs # leave this running
node chat.mjs "Clone https://github.com/sindresorhus/slugify into /workspace, install its dependencies, and run its tests."Four problems we hit building it
git loghung for two minutes. The bash tool runs on a terminal, so any command that opens a pager waits for a keypress until the tool times out. SetPAGER=catin the worker's environment.
- Our client quit after the first tool call. While the worker runs a tool, the session reports
idlewith a stop reason ofrequires_action. Treat a turn as finished only when the session goes idle for any other reason.
- A sleeping sandbox never claims work. The worker's calls out to Anthropic don't keep it awake. Run the worker always on, or wake the sandbox from outside, which is what the orchestrator does.
- Inputs are yours to stage. With no
fileorgithub_repositoryresources, clone or download inputs into/workspacebefore the session starts, or let the agent fetch them.
FAQ
Does a self-hosted sandbox lower the Claude Managed Agents bill?
Does my data stay off Anthropic's servers?
Can one worker run several sessions at once?
ant worker runs one session at a time. Start several workers on the same environment, or give each session its own sandbox as the example does.Which sandbox providers work?
/bin/bash and outbound HTTPS. Anthropic links guides for providers including Cloudflare, Daytona, E2B, Modal, and Vercel. Agent37 runs Anthropic's stock ant worker with no changes.Can the agent run Docker?
agent37-ubuntu template includes Docker.