Skip to content
Guides · Sandboxes and isolation

What is an AI agent sandbox?

Updated November 8, 2026 .md

Short answer: An AI agent sandbox is an isolated computer where an AI agent can run code, install packages and use tools without touching your machine, accounts or other users. The strongest kind is a separate virtual machine with its own kernel that holds only the secrets the task needs and can be paused, copied or thrown away.

Why agents need one#

A coding or computer-use agent does what a developer does: it runs shell commands, installs dependencies, starts servers and reads web pages. Two things make that risky on a machine you care about:

  • Mistakes. A wrong rm, a bad migration or a runaway process hits whatever the agent can reach.
  • Untrusted input. Instructions hidden in a web page, an issue or a file the agent reads can steer it (prompt injection). Then the agent acts with every permission it has.

A sandbox limits the damage to a machine that holds nothing else and that you can throw away.

What an agent sandbox is not#

Your laptop A container on a shared host A microVM sandbox
Kernel Yours The host's, shared with every other container Its own, behind hardware virtualization
What a misled agent can reach Your files, SSH keys, browser sessions, local network The container's mounts, plus the host if a kernel bug or a mounted Docker socket lets it out Only what's inside the VM, plus the internet
Secrets Everything you're signed in to Whatever you mount or pass in Only what you pass in
Running Docker inside Yes, as you Usually needs privileged mode or a mounted socket Yes, as root in its own VM
Cleaning up By hand Remove the container Delete the VM

An agent sandbox isn't a code interpreter that runs one snippet and forgets it, and it isn't a permission prompt in your editor. It's a whole machine you hand the agent. Why the kernel boundary matters, and where gVisor fits, is in container vs microVM for untrusted code. How the two main microVM monitors differ is in Firecracker vs Cloud Hypervisor.

What to look for#

Property Why it matters In a Sandboxer sandbox
Isolation boundary A shared kernel is a bigger attack surface than a hypervisor A Cloud Hypervisor microVM with its own kernel, one per sandbox
Secrets The agent can only leak what's inside --no-env starts with none of your account's secrets; add only what the task needs with -e
Network reach Limits what a misled agent can contact Can't reach other sandboxes or our host and internal networks (except the node's DNS relay); outbound internet is allowed; SMTP port 25 is blocked
A full OS Real tasks need packages, Docker, services Ubuntu 24.04, passwordless sudo, systemd, Docker, /dev/kvm, a streamed desktop with Chrome
Agents Less setup per task Claude Code, Codex, OpenCode, Pi, Kimi Code and Mistral Vibe preinstalled, plus a host command that publishes a port
Lifetime Long tasks shouldn't die mid-way; idle ones shouldn't bill Auto-stop after 1 hour by default, up to 30 days or never; an idle sandbox pauses with its memory and wakes on use
Pause and resume Pick up where the agent left off A stop saves memory and disk; compute isn't billed while stopped; data is kept 14 days after the last stop
Disposable Start clean, throw away after sbx delete when done; fork a copy of the disk to try again
Observable You need to see what it did Command history, process list, streamed agent events, a live desktop
Where it runs Latency and data location us-east (Ashburn, Virginia) or eu-central (Helsinki, Finland)

Sources: Security, Machines, Long-running work, Snapshots, Regions.

See one: a separate VM, and memory that survives a stop#

We ran this on prod on 2026-11-08 with a small sandbox and no account secrets. The create returned ready in about 0.2 s in our test.

sbx new --name demo --type small --no-env --region us-east
sbx exec sb_rpodpsnewv "uname -r; whoami; sudo whoami; systemd-detect-virt; nproc; ls -l /dev/kvm; docker run --rm hello-world | grep Hello"
6.18.56-sandboxer
user
root
kvm
2
crw-rw---- 1 root kvm 10, 232 Nov  2 14:02 /dev/kvm
Hello from Docker!

The sandbox runs its own kernel (6.18.56-sandboxer, not the host's), you're user with passwordless root, it's a KVM guest, and Docker runs inside it.

Now put a value in RAM only (/dev/shm is a memory-backed filesystem), start a process, stop and resume:

sbx exec sb_rpodpsnewv 'head -c 8 /dev/urandom | od -An -tx8 | tr -d " " > /dev/shm/proof; cat /dev/shm/proof; nohup sleep infinity >/dev/null 2>&1 & echo pid=$!'
sbx stop sb_rpodpsnewv --wait
sbx resume sb_rpodpsnewv
sbx exec sb_rpodpsnewv "cat /dev/shm/proof; pgrep -a sleep"
582835e43c5ef9ea
pid=825
…
582835e43c5ef9ea
825 sleep infinity

The value in RAM and the process with the same PID came back, and the sandbox reported memoryRestored: true. In our test the stop took about 2.2 s and the resume about 0.3 s. Then sbx delete sb_rpodpsnewv --yes removed it, and the API answered 404 for it. A resume on a host with a different CPU type boots from disk instead (files kept, processes not), and says so with memoryRestored: false. More in pause and resume a sandbox with memory.

Give an agent a sandbox#

curl -fsSL https://sandboxer.com/install | sh                 # sbx CLI; signs you in
sbx new --no-env -e ANTHROPIC_API_KEY="$ANTHROPIC_API_KEY"     # a VM with only this key
sbx prompt sb_k3v9x2mq --provider claude-code "Clone the repo, run the tests, fix what fails"

We didn't run the sbx prompt line for this page: it needs your own model provider key. See integrated agents.

Or let your own agent create and use sandboxes as tools through MCP: the hosted server at https://sandboxer.com/mcp, or sbx mcp locally. Claude, ChatGPT, Claude Code, Codex, Cursor or any MCP client gets tools to create sandboxes, run commands, move files, publish a port and stop or delete the sandbox. See MCP server.

If you'd rather the model key never enter the VM at all, see keep API keys out of an agent sandbox.

FAQ#

What is an AI sandbox?#

An isolated environment where AI-generated code or an AI agent runs without access to your own computer, data or credentials. It can be a container, a gVisor sandbox or a virtual machine; a VM with its own kernel gives the strongest isolation of the three.

Is a Docker container a safe sandbox for an AI agent?#

It's better than running on your laptop, but containers share the host's kernel. For untrusted or agent-written code, a microVM with its own kernel is a stronger boundary. Never mount the host's Docker socket into an agent's container.

What should an agent sandbox not contain?#

Anything you wouldn't hand to the agent's worst input: your SSH keys, long-lived cloud credentials, production database access and personal browser sessions. Pass only short-lived, narrowly scoped keys for the task.

How long should a sandbox live?#

As long as the task needs. Short code-execution calls can use throwaway sandboxes. Coding agents often need hours or days; then you want one that pauses with its memory when idle and resumes without losing work.

How long does a stopped Sandboxer sandbox keep its data?#

14 days after it last stopped; resuming before then resets the clock. Sandboxes created before October 29, 2026 are kept until you delete them. See snapshots.

Can an agent sandbox use a GPU?#

Not on Sandboxer: there are no GPUs. Sandboxes are CPU-only, in four sizes from 2 vCPU and 4 GB to 16 vCPU and 32 GB.

What does a Sandboxer sandbox cost?#

Plans start at $20/month, charged when you subscribe. A default sandbox (4 vCPU, 8 GB) uses $0.036 of machine time per hour, billed per second while it runs. See pricing.

More guides

Top AI sandbox platforms for code execution in 2026, ranked

For running AI-written code we rank Sandboxer, Freestyle and E2B first: each gives code its own VM with an API or SDK and can pause with memory. Pick Daytona for Windows or GPUs, Modal or Northflank for GPUs at scale, E2B or Northflank to run in your own cloud, and Vercel Sandbox if your app lives on Vercel.

Read the guide
Best sandboxes for running coding agents (Claude Code, Codex, Gemini CLI) in 2026, ranked

For coding agents we rank Sandboxer first: a full Ubuntu VM with Claude Code and Codex preinstalled, Docker, and stop-and-resume that keeps the agent's session in memory. Freestyle and Amp Orbs also keep memory across pauses. Pick E2B for prebuilt agent templates on open source, Docker Sandboxes for free local runs, and Codespaces if you live in GitHub.

Read the guide
Best Daytona sandbox alternatives in 2026, ranked

The best Daytona alternatives depend on why you're switching. For a full Linux microVM on every sandbox with memory-saving stop and Docker, we rank Sandboxer first. E2B suits open source and self-hosting, Modal massive short-job fleets, Northflank bring-your-own-cloud with GPUs, and Vercel Sandbox apps on Vercel.

Read the guide
Best E2B alternatives in 2026, ranked

If you're leaving E2B for longer sessions or a fuller machine, we rank Sandboxer first, then Freestyle: both give each sandbox a full Linux VM that keeps memory across pauses, with Docker and no short session cap. Pick Daytona for Windows or GPUs, Northflank for bring-your-own-cloud, and stay on E2B if you need open source.

Read the guide