The Best Sandboxes for AI Agents in 2027
Nine places to let an AI agent run code safely, ranked by job: microVMs, GPU sandboxes and platform add-ons, with plan limits and a live microVM run.

Give your agent its own microVM, then let it run code that cannot reach the internet. Paste this into your agent:
Set up https://monid.ai/SKILL.md, and then use Monid to create a small Linux machine with smolmachine /machines (python:3.12-alpine, 1 vCPU, 512 MB, 1 GB disk, network allowCidrs limited to the Docker Hub hosts, autoStopSeconds 60). Run a Python snippet in it with /machines/{id}/code that prints the kernel, the CPU count, writes a file to /workspace and tries to reach example.com. Show me the stdout and what each call cost, then delete the machine.
One prompt gives the agent a sealed machine. 1 min setup · 2-4 hrs saved.
If you are building an agent that writes and runs its own code, that code has to run somewhere, and your laptop is the wrong place: it holds your keys, the network is open, and a bad rm is your problem. A shared container is better, but it shares the host kernel and usually the open network too.
A sandbox puts a boundary around the code. The products below all sell one, and differ in what sits around it: GPUs, session length, persistence, and what a sleeping machine costs.
This list ranks nine sandboxes by the job each does best, with each vendor's published limits. Smol Machines takes first place and is a content partner on this guide and a provider you can call through Monid; the measurements are ours. Here is where the list lands:
- Best overall for a persistent, locked-down machine: Smol Machines.
- Best for code sessions you pause and fork: E2B.
- Best when the agent needs a GPU: Modal Sandboxes or Daytona.
Here is the live run behind the hands-on section, through Monid, the OpenRouter for agent tools, with the Smol Machines endpoints.
| Measurement, 2026-11-29 | Value |
|---|---|
| Create a 1 vCPU, 512 MB microVM | 1.7 s |
| First code run, including start and image pull | 5.1 s |
| The Python snippet itself | 160 ms |
| Kernel inside the guest | Linux 6.18.60 |
| Reach example.com | Blocked, DNS did not resolve |
How did we pick these sandboxes?
We judged each option on four things.
- Isolation. A VM boundary or a hardened runtime such as gVisor, not a plain container.
- An API an agent can drive. Create, run and tear down with no console.
- State on your terms. Files that survive a stop, or a clean reset.
- A bill that fits idle time. Agents wait on models between commands.
Two disclosures. Smol Machines is a content partner on this guide and a provider you can call through Monid, and Monid is our product. Every price and limit below comes from the vendor's own page.
What are the best sandboxes for AI agents in 2027?
Nine picks, one job each. Every price here was read from the vendor's page, Verified 2026-11-29.
1. Smol Machines: best for a persistent, network-off machine
Smol Machines runs each workload in its own Linux microVM. The engine, smolvm, is open source under Apache-2.0, uses libkrun as the VMM, and runs on macOS with Apple Silicon, Linux with KVM and Windows. The same machine runs on a laptop, in smol cloud or self-hosted.
Pricing, Verified 2026-11-29: $100 of one-time credit at sign-up; Standard has no monthly fee and allows 20 machines; Pro is $20 a month plus usage. Usage is $0.04 per running machine-hour, $0.05 per vCPU-hour and $0.0162 per GB-hour of memory, with a one-minute minimum and per-second billing after it (pricing).
Features:
- Networking off by default, with egress limited to named hosts.
- Machines persist across restarts; checkpoints capture RAM, CPU state and disk.
- A stopped machine bills disk only.
2. E2B: best for code sessions you pause and fork
E2B gives every session a Firecracker microVM built for agent code. Sandboxes pause with filesystem and memory and fork up to 100 copies from a saved state.
Pricing, Verified 2026-11-29: Hobby has no plan fee and one-time $100 in credits, with sessions up to 1 hour; Pro is $150 a month plus usage, with 24-hour sessions; vCPU at $0.000014 per second (pricing).
Limit to plan for: E2B states it does not offer GPU sandboxes.
3. Daytona: best for long-running agent workspaces
Daytona claims sandbox creation in under 90 ms and says its sandboxes run indefinitely. It also offers Windows and macOS sandboxes, and rents GPUs next to CPU machines.
Pricing, Verified 2026-11-29: $200 in free compute; $0.0504 per vCPU-hour and $0.0162 per GiB-hour of memory, billed per second; preemptible H100 at $2.47 an hour (pricing).
4. Modal Sandboxes: best when the agent needs a GPU
Modal Sandboxes run untrusted code on gVisor or on a VM runtime, inside the same platform that serves Modal's Python functions. GPU sandboxes are supported on the gVisor runtime, and a sandbox lives up to 24 hours.
Pricing, Verified 2026-11-29: Starter has no plan fee and $30 a month in free credits; sandboxes bill at 3x the list CPU and memory rate (pricing).
5. Vercel Sandbox: best if your app already ships on Vercel
Vercel Sandbox runs each sandbox in a Firecracker microVM, persists state by default and resumes where it stopped. Active CPU excludes time spent waiting on I/O, which suits an agent that waits on a model.
Pricing, Verified 2026-11-29: Hobby is free within 5 active CPU hours a month, with sessions up to 45 minutes; Pro sessions run 24 hours, active CPU at $0.128 an hour in iad1 (pricing).
6. Cloudflare Sandbox SDK: best for agents built on Workers
The Cloudflare Sandbox SDK starts a microVM with its own kernel and network from a Durable Object, so a Worker can hand code to a sandbox in a few lines. Stopped instances are not billed, and filesystem snapshots are in beta.
Pricing, Verified 2026-11-29: requires Workers Paid at $5 a month, which includes 375 vCPU-minutes and 25 GiB-hours of memory (pricing).
7. Fly.io Sprites: best for a computer with its own URL
Sprites are hardware-isolated Linux computers that keep their disk, answer on their own URL, sleep when idle and wake on the next request. Checkpoints snapshot the whole filesystem in about a second.
Pricing, Verified 2026-11-29: $0.0385 per CPU-hour and $0.021875 per GB-hour of memory, billed only while running; a $1 trial credit with no card (pricing).
8. Runloop: best for coding agents that branch state
Runloop sells devboxes on micro-VMs, with snapshot and branch from disk state, aimed at coding agents and their evaluation runs. Suspended devboxes accrue no compute or memory charges.
Pricing, Verified 2026-11-29: $50 in credits with no card; Pro is $250 a month plus usage (pricing).
9. Northflank: best for scale or your own cloud
Northflank sandboxes run on Cloud Hypervisor microVMs, or on gVisor for GPUs, with no time limit, and can run in your own cloud account (BYOC).
Pricing, Verified 2026-11-29: from $0.01667 per vCPU-hour, billed per second; GPUs from L4 to B200 (pricing).
Why does Smol Machines come first?
Smol Machines comes first for one job: an agent that needs a machine it keeps, cannot leak from, and that you can also run on your own laptop. That is the common case for a coding agent, and three things separate Smol there.
The network is closed until you open it. Networking is off by default and egress is limited to named hosts (smolvm). In our run the machine could pull its image from Docker Hub and nothing else: example.com did not even resolve.
The machine is yours, not a session. Files and installed packages survive stop and start, a stopped machine bills only disk, and there is no session cap like E2B Hobby's 1 hour or Vercel Hobby's 45 minutes, Verified 2026-11-29.
Local and cloud are the same machine. The engine is open source and runs on a Mac, so the agent's environment in development is the one it gets in production.
Where others win: for a GPU, take Modal, Daytona or Northflank. To pause a session with its memory and fork it, take E2B. Inside Vercel or Cloudflare, their own sandboxes save you a second account.
How to give your agent a microVM with Monid
Three steps: install, create the machine, run code in it. Monid supplies one key and one balance; the machine is Smol Machines'. The Smol Machines × Monid launch page walks through a longer session, and the smolmachine endpoint list has every call.
Step 1. Install and add your key
For agents. Get an API key at app.monid.ai, then give your agent the key and this line. The agent quickstart explains the workflow.
set up https://monid.ai/SKILL.md
For humans. Install the CLI and save your key. The CLI quickstart covers the rest.
npm install -g @monid-ai/cli
monid keys add -k <your-api-key> -l main
Step 2. Create the machine
Size and network are required. The upstream default is 4 vCPU, 8 GB and an open network, which you rarely want for agent code.
monid run -p smolmachine -e /machines \
-i '{"source":{"type":"image","reference":"python:3.12-alpine"},"resources":{"cpus":1,"memoryMb":512,"diskGb":1},"network":{"mode":"allowCidrs","hosts":["registry-1.docker.io","auth.docker.io","production.cloudflare.docker.com"]},"workdir":"/workspace","autoStopSeconds":60}' \
-w -j
It returned in 1.7 seconds with HTTP 201 and a machine id. Machines are created stopped; the first command starts them, and autoStopSeconds stops it after a minute idle.
Step 3. Run code in it
/machines/{id}/code takes source as a field, so the agent never fights shell quoting.
monid run -p smolmachine -e "/machines/{id}/code" \
--path '{"id":"mach-..."}' \
-i '{"language":"python","code":"import platform, os\nprint(platform.release(), os.cpu_count())"}' \
-w -j
Our snippet printed the kernel, wrote a file and tried the internet. The call took 5.1 seconds on a cold machine, image pull included; the code ran in 160 ms.
| Field | What came back |
|---|---|
stdout | kernel 6.18.60, python 3.12.16, cpus 1, mem_mb 513 |
/workspace | note.txt, written by the agent |
| Network test | example.com blocked: gaierror |
exitCode | 0 |
For longer jobs, /machines/{id}/exec/async runs past the 25-second cap. Delete with /machines/{id}/delete, or set ttlSeconds at creation.
How much does a sandbox for an agent cost?
The nine bill in three shapes, and idle time decides which is cheapest. Every figure here is Verified 2026-11-29; live per-call prices are on monid.ai/tools.
Per second of use, no plan. Smol Machines, Daytona, Sprites and Northflank charge for what runs, with a free credit or tier to start. A sleeping Smol machine pays disk only.
Plan plus usage. E2B Pro at $150 a month, Runloop Pro at $250 and Modal Team buy longer sessions and more concurrency on top of usage, Verified 2026-11-29.
Inside a platform you already pay for. Vercel and Cloudflare bill sandboxes against Vercel Pro credit or Workers Paid at $5 a month, Verified 2026-11-29.
Through Monid, the Smol Machines API calls carry no per-call fee and the machine meters its own usage against the balance your other tools use. Our whole run came to a fraction of a cent. Other machines are in the compute and storage tools.
Which sandbox for which job?
Each row names the job first. To run the first pick from the same key as your other tools, start from /tools/compute.
| Use case | Best sandbox | Why? (prices Verified 2026-11-29) |
|---|---|---|
| A coding agent's own machine, locked down | Smol Machines | Network off by default, persists, runs locally too; $100 credit |
| Code sessions you pause and fork | E2B | Memory snapshots, up to 100 forks; $100 credit, then Pro $150 a month |
| Long sessions, Windows or macOS | Daytona | Runs indefinitely; $200 free compute |
| GPU work on untrusted code | Modal Sandboxes | GPU on gVisor; $30 a month credit |
| An app already on Vercel | Vercel Sandbox | Firecracker, persistent by default; free within Hobby quota |
| An agent on Workers | Cloudflare Sandbox SDK | microVM from a Durable Object; Workers Paid $5 a month |
| A machine with its own URL | Fly.io Sprites | Sleeps and wakes on request; $0.0385 per CPU-hour |
| Coding evals that branch state | Runloop | Snapshot and branch devboxes; $50 credit |
| Thousands of sandboxes or BYOC | Northflank | No time limit, own cloud; from $0.01667 per vCPU-hour |
When is a local container enough?
A local container is enough when the code is yours and trusted: tests you wrote, a script you reviewed.
It stops being enough when a model writes the code, installs packages you have not read, or runs longer than your laptop stays open. And if the agent mostly clicks through websites rather than running code, it wants a browser, not a machine: try the Browser Use agent endpoint or TinyFish on Monid, whose browser automation endpoint drives a real browser.
Conclusion
You now have nine sandboxes sorted by job, the published limits behind each, and a run that put an agent's Python in a sealed microVM in under seven seconds. Start with Smol Machines when the agent needs a machine of its own with the network shut, take Modal or Daytona for a GPU and E2B to pause and fork. The 2 to 4 hours saved is our estimate for opening a sandbox account, wiring its SDK and writing teardown for one agent.
FAQ
What is the best sandbox for AI agents?
For a persistent machine with the network closed by default, Smol Machines. For GPU work, Modal Sandboxes or Daytona. To pause and fork sessions, E2B.
What is a microVM sandbox?
A small virtual machine with its own kernel, built to start fast. Firecracker (E2B, Vercel), libkrun (Smol Machines) and Cloud Hypervisor (Northflank) are the common engines.
Is a Docker container safe for agent-written code?
Not on its own. A container shares the host kernel and usually has an open network. A microVM or gVisor adds a boundary the code cannot cross.
Can an AI agent keep files between sessions?
Yes on Smol Machines, Daytona, Sprites and Vercel, where state persists across stop and start. In our run the agent wrote to /workspace, which Smol Machines keeps across a stop.
Which sandboxes offer GPUs?
Modal, Daytona and Northflank list GPUs on their pricing pages, Verified 2026-11-29. E2B states it does not offer GPU sandboxes.
This list is based on public information read on November 29, 2026 and is not an endorsement by any vendor named.
Published November 2026.


