AI agent sandboxes compared
Six places to run an AI agent's code and tools in isolation: E2B, Daytona, Modal Sandboxes, Vercel Sandbox, Cloudflare Sandboxes and a persistent VM per agent, with how each isolates code and what it keeps between runs.
Reviewed
An AI agent sandbox is an isolated machine where an agent runs the code it writes, the commands it chooses and the tools it installs, without touching your own servers or another user's data. Coding agents, data-analysis agents and computer-use agents all need one, and a handful of platforms now sell them as an API call.
This guide compares the sandboxes teams actually build on: how each one isolates the agent's code, how long a sandbox can run, and what survives once it stops. That last question decides more agent architectures than start-up time does.
What a sandbox has to do for an agent
A sandbox for a script runs it once and throws everything away. A sandbox for an agent is asked for more, because the agent decides what to run and keeps coming back:
- Contain code nobody reviewed: the model wrote it a second ago, and a prompt injection may have written part of it.
- Give the agent a real environment: a shell, a filesystem, a package manager, often a browser or a desktop.
- Control what leaves: which hosts the agent can reach and which credentials it can see.
- Keep the agent's work between steps and between sessions, or make it cheap to rebuild.
- Cost little while the agent is waiting on a model, a user or a webhook, which is most of the time.
Three ways to isolate agent code
Plain containers share the host's kernel and separate processes with namespaces and cgroups. They start fast and are familiar, but a kernel bug is a path out, which is why platforms that run untrusted code add another layer.
gVisor puts a user-space kernel between the container and the host, so the agent's system calls are handled by gVisor rather than the host kernel. It keeps the container workflow with a smaller attack surface; some workloads that expect a full Linux kernel don't run under it.
MicroVMs, such as Firecracker, give every sandbox its own kernel behind hardware virtualisation. They are the strongest of the three boundaries and, because the whole machine is one unit, they can be paused, snapshotted and resumed with memory intact. Most of the platforms below offer a VM option for that reason.
At a glance
| Option | Best for | What survives between runs | Self-host |
|---|---|---|---|
| E2B | Coding and data-analysis agents, and computer-use agents that need a Linux desktop. | Pausing saves the filesystem and memory, and a paused sandbox is kept until you kill it. | BYOC: a managed deployment in your own AWS, Google Cloud or Azure account, for Enterprise customers. |
| Daytona | Agents that need Windows, macOS or GPUs alongside Linux, or one sandbox kept per project. | Persistent by default: stopping keeps the filesystem; VM sandboxes can also pause with memory intact, and volumes outlive any one sandbox. | Bring Your Own Compute: your own runner nodes in custom regions, managed by Daytona's control plane (enabled per organisation). |
| Modal Sandboxes | Teams already on Modal, and agents that need GPUs or heavy data work next to their code. | A sandbox ends when it finishes; filesystem snapshots and volumes carry files into the next one. | No; it is a cloud platform. |
| Vercel Sandbox | Teams building agents on Vercel and its AI SDK. | Persistent by default: the filesystem is snapshotted when a session stops and restored on the next resume. | No; it runs on Vercel. |
| Cloudflare Sandboxes | Applications already on Workers, and short, tightly fenced code runs at the edge. | Directory backups to R2 and mounted S3-compatible buckets; check the docs for how long an idle container lives. | No; it runs on Cloudflare. |
| A persistent VM per agent (Maritime) | Long-lived agents, one per end user, whose tools and files should stay put. | The whole disk: installed packages, browser profile, downloads and working files survive sleep. | No; it is a cloud platform. |
The sandboxes
1. E2B
Isolated cloud sandboxes for agents, each a Linux VM created on demand from a template with its Python or JavaScript SDK. A Code Interpreter SDK adds stateful code execution, and E2B Desktop sandboxes give computer-use agents an Ubuntu desktop they can see and control. Its SDK is open source under Apache 2.0.
- Best for: Coding and data-analysis agents, and computer-use agents that need a Linux desktop.
- Between runs: Pausing saves the filesystem and memory, and a paused sandbox is kept until you kill it.
- Self-host: BYOC: a managed deployment in your own AWS, Google Cloud or Azure account, for Enterprise customers.
- Keep in mind: Continuous runtime is capped by plan (E2B's docs list 1 hour on Hobby and 24 hours on Pro); pausing and resuming resets the clock.
- Keep in mind: Sandboxes are CPU-only; E2B's docs say there is no GPU option.
Check e2b.dev for current features, limits and pricing.
2. Daytona
Infrastructure for running AI-generated code in sandboxes with their own filesystem, network stack and allocated vCPU, RAM and disk. Sandboxes come as containers, Linux VMs, Windows and macOS machines, or GPU containers, with SDKs for TypeScript, Python, Ruby, Go and Java and agent tools for files, Git, processes, computer use and VNC.
- Best for: Agents that need Windows, macOS or GPUs alongside Linux, or one sandbox kept per project.
- Between runs: Persistent by default: stopping keeps the filesystem; VM sandboxes can also pause with memory intact, and volumes outlive any one sandbox.
- Self-host: Bring Your Own Compute: your own runner nodes in custom regions, managed by Daytona's control plane (enabled per organisation).
- Keep in mind: What persists depends on the sandbox class: GPU sandboxes are deleted on stop, and container sandboxes clear memory on every stop.
Check daytona.io for current features, limits and pricing.
3. Modal Sandboxes
Secure containers on Modal's serverless platform for running LLM-generated or user-submitted code, created from Python, JavaScript or Go. Each runs under gVisor or, for workloads that need a full Linux kernel such as Docker-in-sandbox, in a VM. Sandboxes use the same images, volumes and secrets as Modal Functions, and can have GPUs on the gVisor runtime.
- Best for: Teams already on Modal, and agents that need GPUs or heavy data work next to their code.
- Between runs: A sandbox ends when it finishes; filesystem snapshots and volumes carry files into the next one.
- Self-host: No; it is a cloud platform.
- Keep in mind: The default lifetime is 5 minutes and the maximum 24 hours; Modal recommends snapshots for anything longer.
Check modal.com for current features, limits and pricing.
4. Vercel Sandbox
Isolated Linux microVMs for running untrusted or agent-generated code, driven from Vercel's TypeScript or Python SDK or its CLI. It adds outbound network controls, credentials Vercel sets up from your team's configuration, live previews, and Drives (in private beta) for files an agent needs after a run ends. The SDK is open source under Apache 2.0.
- Best for: Teams building agents on Vercel and its AI SDK.
- Between runs: Persistent by default: the filesystem is snapshotted when a session stops and restored on the next resume.
- Self-host: No; it runs on Vercel.
- Keep in mind: A single session runs for up to 45 minutes on Hobby and up to 24 hours on Pro and Enterprise, per Vercel's docs.
- Keep in mind: Persistence restores files, not running processes; anything in memory starts again on resume.
Check vercel.com for current features, limits and pricing.
5. Cloudflare Sandboxes
Two sandboxes reached through a Cloudflare Worker: Containers, a full Linux microVM with its own kernel and network started from an image you provide, and Dynamic Workers, which load untrusted JavaScript, Python or WebAssembly as a new, separate Worker. Your Worker decides what each sandbox can reach, including whether it gets the internet at all.
- Best for: Applications already on Workers, and short, tightly fenced code runs at the edge.
- Between runs: Directory backups to R2 and mounted S3-compatible buckets; check the docs for how long an idle container lives.
- Self-host: No; it runs on Cloudflare.
- Keep in mind: It needs the Workers Paid plan, and the scheduling policy sandbox containers use is in public beta.
Check developers.cloudflare.com for current features, limits and pricing.
6. A persistent VM per agent (Maritime)
Instead of creating a sandbox for each task, each agent gets its own computer. Maritime runs every machine as its own Firecracker micro-VM with its own disk; it sleeps when idle and wakes in about a second, and it is billed per second. The agent installs what it needs once and finds it there next time, and can also get Linux and Windows desktops or Android phones to operate.
- Best for: Long-lived agents, one per end user, whose tools and files should stay put.
- Between runs: The whole disk: installed packages, browser profile, downloads and working files survive sleep.
- Self-host: No; it is a cloud platform.
- Keep in mind: A machine that keeps everything also keeps mistakes; plan how you reset or rebuild one. Check Maritime's docs for its snapshot and template options.
- Keep in mind: This site is published with Maritime, which is why it is on this list. Weigh it like the others.
Check maritime.sh for current features, limits and pricing.
How to choose
All six will run an agent's code safely enough for most teams. What separates them is the shape of your agent:
- Does each task start clean? If the agent runs a snippet and returns a result, short-lived sandboxes (Modal, Cloudflare, E2B without pausing) are the simplest fit.
- Does the agent come back to its work? If it should find its packages, repository and files where it left them, look for sandboxes that persist by default (Daytona, Vercel Sandbox), pause with memory (E2B, Daytona VMs) or a machine per agent (Maritime).
- Does it need more than Linux? Daytona offers Windows and macOS sandboxes; E2B Desktop and Maritime give agents a desktop to operate; Modal and Daytona offer GPUs.
- Where must it run? Daytona can run on your own compute and E2B in your own cloud account; the rest are hosted.
- What does it reach? Prefer a sandbox where you set outbound network rules and inject credentials per run, rather than baking keys into an image.
A note on pricing
Sandboxes are billed per second of CPU and memory, per active CPU, per session or per plan, and stopped or paused sandboxes are often billed separately for storage. Prices change, so none are listed here. Price one real workload on each vendor's pricing page: how many sandboxes a day, how long each one is busy, how long it sits idle, and how much disk it keeps. For agents that mostly wait, idle and storage costs decide the total.
Questions people ask
What is an AI agent sandbox?
An isolated environment, usually a container or a small virtual machine, where an agent runs the code and commands it generates. It keeps that code away from your own systems and other users' data, and gives the agent a shell, a filesystem and usually network access you control.
Is a Docker container enough to sandbox an AI agent?
A plain container shares the host's kernel, so it is a weaker boundary for code nobody reviewed. Platforms that run untrusted agent code add gVisor or run each sandbox in its own microVM. If you run containers yourself, treat the agent like an untrusted user: no host mounts, no shared credentials and restricted outbound traffic.
Which AI agent sandboxes can I run on my own infrastructure?
Daytona's Bring Your Own Compute runs sandboxes on your own runner nodes under its control plane, and E2B's BYOC deploys into your own AWS, Google Cloud or Azure account for Enterprise customers. Modal, Vercel Sandbox, Cloudflare and Maritime are hosted.
Which sandbox keeps an agent's state between sessions?
E2B pauses with filesystem and memory and keeps paused sandboxes until you delete them. Daytona and Vercel Sandbox persist the filesystem by default. Modal and Cloudflare carry state through snapshots, volumes or backups. A persistent VM per agent keeps the whole disk.
Further reading
- Computer-use agents: models, frameworks and where to run them
- Browserbase alternatives for AI browser agents
- Computer-Use Agent Sandboxing Requirements
- Browser Agent Isolation With Firecracker Micro-VMs
- Stateful vs Stateless Architecture Tradeoffs for Computer-Use Agents
- Snapshot and Restore for Idle Browser Agent VMs
- Credential and Secret Injection in Computer-Use Agent Environments
- File System Access Patterns for Computer-Use Agents