Can Your Self-Hosted Sandbox Survive a Worker Loss?

Choose the agent loop’s location separately from tool execution, then replay a degraded worker pool before committing to self-hosted capacity.

Map what crosses the worker boundary

For Claude Managed Agents, moving to a self-hosted sandbox changes where tools run while Anthropic still runs Claude and receives tool results. Make that interface concrete with a synthetic fixture containing one harmless marker in a file and a different marker in the tool response. Record the response visible to the agent, the artifact that remains on the worker, and which logs contain either marker. Review the same boundary for Cursor Self-Hosted Machines if you are choosing between hosted control planes. If your policy governs tool outputs as well as repository placement, inspect the returned fields before approving the design. Use a self-hosted Agent SDK deployment as a separate architecture to evaluate when the loop itself must run on infrastructure you control. Confirm model inference and telemetry separately for that option.

Choosing an agent environment - Claude Platform Docs

Set a drain target for a degraded pool

When you host the Claude Agent SDK loop, budget worker slots around live sessions. The SDK supervises a subprocess that owns working files and session state, so a host replacement can create a state recovery problem alongside a capacity problem. For a pilot, submit an illustrative burst of 18 jobs to four single-slot workers, then repeat with one slot unavailable from the start. If every job holds its slot for 40 seconds, a 200-second deadline fits 20 jobs in the healthy run and 15 in the degraded run. Log enqueue, slot acquisition, and completion timestamps. For a separate recovery check, resume one synthetic session on a fresh worker and verify its last committed output. A queue that drains on time can still fail this recovery check if session data and working artifacts migrate independently.

Hosting the Agent SDK - Claude Code Docs

Split the agent loop from the sandbox before choosing

A self-hosted AI agent is not one deployment decision. Separate the component that decides the next action from the isolated workspace where commands and file edits run. Anthropic's documentation describes an environment as the place where tools and code run in a sandbox, and offers a cloud environment, where each session gets a fresh Linux container on Anthropic-managed infrastructure, or a self-hosted sandbox, where you run the sandbox on your own infrastructure while Claude runs on Anthropic's side and the agent definition stays the same.

That split gives a concrete first question: which responsibility do you want to own? If you are unsure, the documentation recommends starting with a cloud environment because there is nothing for you to host. Choose self-hosting only when tools must run on infrastructure you control. Log where prompts, files, credentials, and tool results travel before labeling anything self-hosted.

This is an illustrative decision frame, not a measured performance result. Write down the boundary you pick, then confirm it in a test session before commissioning hosts.

Choosing an agent environment - Claude Platform Docs

Match the isolation design to your workload

The sandbox option changes the isolation boundary. Docker's docs compare local and cloud sandboxes: local uses host resources, can mount host paths or use a private Git clone, and can use host GPU, USB, display, and nested virtualization, while cloud uses Docker-managed cloud resources, has no access to host paths, and exposes ports through a public HTTPS URL. Local secrets come from the local sbx secret store; cloud reads a separate cloud secret store, and local policies are not copied to cloud.

Those differences are work items, not footnotes. If your workload needs a GPU or a host path, a cloud sandbox without host hardware access will not run it, and you must transfer files or clone a repository inside the sandbox instead. Verify network policy and secret scope separately because each environment has its own store.

Run your dependency install, build, tool calls, and file writes on the candidate environment. A passing launch does not prove your workload fits; the failing resource or mount does.

Compare local and cloud sandboxes | Docker Docs

Weigh state and concurrency before self-hosting the loop

If you consider running the agent loop itself rather than only its sandbox, hosting changes character. The Agent SDK spawns and supervises a claude CLI subprocess owning a shell, working directory, and session files on disk, and one agent session maps to one subprocess, so N concurrent sessions take N subprocesses. Each has its own process tree and transcript file, and by default they inherit the application's working directory unless you pass a distinct cwd.

That makes self-hosting the loop a stateful capacity decision. Plan for process-per-session resource use, separate working directories per session, and durable session storage. If you do not need the agent loop on your own infrastructure, the same documentation points to Managed Agents, where Anthropic hosts the loop and tool execution runs in an Anthropic-managed or self-hosted sandbox.

Troubleshooting case: sessions sharing one working directory can collide on files and transcripts. Assign distinct cwd values and confirm transcripts are written where you expect before scaling concurrency.

Hosting the Agent SDK - Claude Code Docs

Sources