The Best Sandboxes for Claude Agents in 2026
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.
Frequently asked questions
Does the Claude Agent SDK come with a sandbox?
No. The SDK ships built-in tools — Bash, Read, Write, Edit, Glob, Grep, WebSearch — and all of them execute in the process hosting your agent, with that process's filesystem, environment, and network access. That's the right design for a developer running an agent on their own machine against their own code. It is not isolation, and behind a web app it means any user-supplied content in the model's context is a potential prompt injection with shell access. You add a sandbox yourself, by removing the built-ins and exposing a sandboxed equivalent through an in-process MCP server.
What's the difference between Managed Agents and the Claude Agent SDK?
They solve different halves of the problem. The Agent SDK supplies a harness — the agent loop, context management, built-in tools — but you host and deploy it, and the tools run on your infrastructure. Managed Agents supplies both the harness and the deployment: Anthropic runs the loop and provisions a per-session container where bash, file operations, and code execution happen. Choose the SDK when you want the agent's compute on your own infrastructure; choose Managed Agents when you'd rather not run any.
Do I really need microVM isolation, or is a container enough?
It depends entirely on whether the code being executed can be influenced by input you don't control. If your agent only ever runs code paths you wrote, against data you own, a container is a reasonable boundary. The moment the model's context can include a user's document, a fetched web page, or a support ticket, a prompt injection can make the agent write and run arbitrary code — and at that point you're relying on a shared kernel to separate an attacker from your host. A microVM gives the guest its own kernel behind hardware virtualization, which is the boundary cloud providers use between unrelated customers.
How much does running a sandbox per conversation actually cost?
It depends almost entirely on the billing model rather than the sandbox. If you're charged a flat rate for every hour a sandbox exists, one per conversation is expensive and you'll be pushed toward pooling — which undoes the isolation. If you're charged per second for CPU actually burned and memory actually resident, the long stretches where the sandbox sits idle waiting for a model response cost close to nothing. On PandaStack that's $0.000015 per active vCPU-second and $0.0000045 per working-set GiB-second, so per-conversation isolation ends up being the cheap option as well as the safe one.
Can I switch sandbox providers later without rewriting my agent?
Mostly, if you structure it right. The integration surface is one or two tool functions — take code, run it somewhere, return structured results — so keeping that behind a thin interface of your own makes the vendor swappable. What doesn't port cleanly is anything provider-specific you come to depend on: fork semantics, snapshot formats, custom template builds, or a persistent-kernel abstraction with a particular result shape. Those are usually worth depending on, but depend on them knowingly, and prefer a provider whose self-hostable or open-source version gives you an exit that doesn't require a rewrite.
Keep reading
49ms p50 cold start. Fork, snapshot, and scale to zero.