Two things happened in the last year that changed this question. Anthropic shipped the Claude Agent SDK, which is Claude Code as a library — the agent loop, context management, subagents, and a set of built-in tools that read files and run shell commands. And it shipped Managed Agents, where Anthropic runs the loop and hosts the container the tools execute in. Between them, 'where does my Claude agent run code' now has genuinely different answers depending on which of those you're building on.
This is a field guide to those answers. It's organised by the constraint that actually forces the decision, because the right pick flips completely depending on which one is binding for you.
First, work out which question you're asking
There are three distinct shapes here and people conflate them constantly:
- You're using the Claude Agent SDK and want its Bash and file tools to stop running on your server. You need a sandbox you can reach from a custom tool, plus the discipline to remove the built-ins.
- You're calling the Messages API directly with your own tool loop, and you need somewhere for the code tool to execute. Same sandbox requirement, simpler integration — it's one function.
- You want Anthropic to run the whole thing. Managed Agents gives you a hosted loop and a per-session container; you write an agent config, not infrastructure.
If you're in the third bucket and happy there, most of this article is moot — the sandbox is included. It stops being moot the moment you need the code to run somewhere specific: inside your VPC, on your own hardware, under a data-residency rule, or with access to an internal database that isn't on the public internet.
The isolation question, stated once
Everything below runs code. What differs is the boundary around it, and the honest hierarchy is short: a container shares your host kernel, so a kernel escape is a host compromise; a syscall-filtering runtime like gVisor puts a userspace kernel in the way, trading some syscall performance for a much smaller attack surface; a microVM gives the guest its own kernel behind hardware virtualization, which is the same boundary your cloud provider uses between its customers.
For an agent that only ever runs code you wrote, a container is fine. For an agent whose context includes anything a user supplied — and that's almost every agent that touches a document, a web page, or a support ticket — you should assume the code being executed is adversarial, because a prompt injection makes it so.
The options
Anthropic Managed Agents
Anthropic hosts the agent loop and provisions a container per session as the agent's workspace. Bash, file operations, and code execution run there. Agents are persisted, versioned objects; sessions pin to a version, and there's a scheduled-deployment path for agents that run on a cron cadence.
Shines when: you want the least infrastructure you own. No loop code, no state files, no scheduler. The credential story is genuinely good — vault-backed environment variables are substituted at egress, so a secret never enters the sandbox at all.
Caveat: it's Anthropic's compute, on Anthropic's network. If the agent needs to reach a private database, or the data can't leave your infrastructure, this is the wrong shape and no amount of configuration fixes it.
PandaStack
Ours: Firecracker microVMs behind an API, open-source and self-hostable. Each sandbox gets its own kernel under KVM. Create is a snapshot restore rather than a boot, so a fresh sandbox is a couple of hundred milliseconds rather than seconds — the measured p50 is 179ms.
That number matters more than it looks, because it decides your architecture. When sandbox creation is slow, teams pool sandboxes across users to hide the latency, which reintroduces exactly the isolation problem they were trying to solve. When it's fast, one sandbox per conversation is simply the obvious choice.
The other differentiator is forking. A sandbox can be forked so children inherit the parent's disk state, or fork-tree'd so N children inherit memory and disk both — a warm process, a loaded model, a populated cache — at roughly 400–750ms per child on the same host. For best-of-N agent runs, that means you set up the expensive state once and branch it, instead of paying for it N times.
Billing is per-second on what's actually used: $0.000015 per active vCPU-second and $0.0000045 per working-set GiB-second. The seconds an agent spends waiting on a model response cost close to nothing, which is the majority of wall-clock time in any agent loop.
Caveat: it's a younger platform than the incumbents, and the managed offering runs in fewer regions than a hyperscaler. If you need a specific region today and don't want to self-host, check before you build.
E2B
The company that popularised the shape: an API that hands your agent an isolated sandbox with a code interpreter. Mature SDKs, a well-designed persistent-kernel abstraction, and an ecosystem of templates.
Shines when: you want the most established option for exactly this job and don't need to self-host. The developer experience is the reference implementation everyone else is measured against.
Caveat: hosted-only in practice for most teams, and it's a sandbox product rather than a platform — if you also need a database, an app to serve, or a cron job, that's separate vendors and separate bills.
Modal
A serverless compute platform with a Python-native programming model and strong GPU support, which teams increasingly use as an agent sandbox by way of its sandbox primitive.
Shines when: the agent's work is compute-heavy — model inference, batch processing, anything wanting a GPU. Modal's scheduling and image-building story is excellent and the Python ergonomics are unusually good.
Caveat: the mental model is functions-and-images, not machines. That's a great fit for a workload and a slightly awkward one for a long-lived interactive session where an agent wants to poke at a filesystem across many turns.
Daytona
Grew out of the dev-environment world and repositioned toward agent sandboxes. The heritage shows in the strengths: workspace-shaped environments, good repo and toolchain handling.
Shines when: the agent's job is development work — clone a repo, install dependencies, run tests, open a PR. That's the use case it was built around.
Caveat: if your agent is doing short data-analysis bursts rather than long development sessions, you're paying for a heavier environment than the task needs.
Vercel Sandbox
Ephemeral compute for running untrusted code, sitting alongside the rest of the Vercel platform and integrating naturally with the AI SDK.
Shines when: your app already lives on Vercel. One vendor, one bill, one auth story, and the integration path is short.
Caveat: it's designed around the Vercel-shaped workload. Outside that platform the gravitational pull isn't there, and long-running or stateful sessions are not what it optimises for.
Rolling your own on Firecracker or gVisor
Both are open source and both are what the platforms above are built on. If you have a platform team and unusual requirements — a specific kernel, air-gapped hardware, a compliance regime that rules out multi-tenant infrastructure — this is a real option and not a foolish one.
Caveat, and it's the big one: the VMM is the easy part. The work is everything around it — network namespace allocation and reclamation, snapshot storage and invalidation, filesystem copy-on-write, idle reaping, and the metering you need to know what any of it costs. Budget quarters, not weeks. I know because we did it.
Which one, by the constraint that's forcing your hand
- You want the least infrastructure and the data can live on Anthropic's side → Managed Agents.
- Untrusted input reaches the model, and you want hardware isolation with per-second billing → PandaStack, or another microVM-based provider.
- You want the most established sandbox API and don't need to self-host → E2B.
- The agent's work needs a GPU → Modal.
- The agent is doing development work in a repo → Daytona.
- Your app is already on Vercel → Vercel Sandbox.
- Data residency or air-gapping rules out hosted anything → self-host, either an open-source platform or raw Firecracker.
What to actually test before you commit
Every vendor here will run a Python script and hand you back stdout. That baseline separates nothing. These are the five things that turn out to matter after you've shipped:
- Cold create latency, measured yourself, from the region you'll run in. It sets whether you can afford one sandbox per conversation.
- Whether state persists across tool calls. A stateless code tool forces the agent to rewrite its whole pipeline every turn, which burns tokens and produces more fragile generated code.
- What idle costs. An agent spends most of its wall-clock time waiting for the model, and whether that time is billed at provisioned rates or near zero changes your unit economics by an order of magnitude.
- Whether you can fork. Best-of-N and branch-and-explore patterns are dramatically cheaper when you can duplicate a warm environment instead of rebuilding it.
- The exit. Can you take the workload elsewhere without rewriting your agent? An open-source or self-hostable option is worth something even if you never exercise it.
The bottom line: if you're building on the Claude Agent SDK, the single most important thing isn't which vendor you pick — it's that you remove the built-in host-side tools and route execution somewhere isolated at all. Everything above is a choice about where. Leaving Bash pointed at your own process is a choice too, and a worse one.