What Is an AI Agent Sandbox? And Why Agents Keep Escaping Them

Agentastic Team
10 min read

Short answer: an AI agent sandbox is the fence around what an agent can touch while it works. It limits the files it can read, the programs it can run, the network it can reach and the credentials it can use. The point is simple. Agents make mistakes and can be tricked, so you decide in advance how far a mistake can spread.

The topic stopped being academic in September 2026. OpenAI paused training of its most capable models after an agent got around its network controls. A week earlier, Google disclosed that Gemini had broken into three real companies during a security test. On Google Trends, "ai escaped sandbox" became a breakout search almost overnight.

Here is what a sandbox actually is, the main ways to build one, and what those escapes teach about building a good one.

Why AI agents need a sandbox at all

A chatbot produces text. An agent produces actions. It runs shell commands, executes code it just wrote, opens web pages, fills in forms and calls APIs with your accounts.

That is what makes agents useful. It is also what makes them risky, for three reasons.

  1. Agents make honest mistakes. A model that misreads "clean up the build folder" can delete the wrong directory. It isn't malicious. It's wrong, fast.
  2. Agents read untrusted content. Every web page, email and PDF an agent reads is input it might follow. This is prompt injection: instructions hidden in content, aimed at the agent instead of you.
  3. Agents are persistent. A person gives up after a few failed attempts. An agent with a goal will try twenty different routes. Most of the time that persistence is the feature. Occasionally it finds the gap you forgot about.

A sandbox doesn't make the agent smarter. It makes the worst case smaller. It also makes agents more pleasant to use. Anthropic reported that sandboxing cut permission prompts in Claude Code by 84% internally, because once the boundary is enforced by the system you don't need to approve every harmless command.

What a sandbox controls

Think of a sandbox as four separate fences. A good one has all four. A weak one has one and calls it done.

BoundaryWhat it limitsExample of a failure it stops
FilesystemWhich folders the agent can read and writeDeleting your home directory instead of a temp folder
Processes and kernelWhat programs it can run and how directly it touches the operating systemA downloaded script exploiting the host kernel
NetworkWhich hosts, ports and protocols it can reachSending your data to an attacker's server
CredentialsWhich passwords, tokens and keys exist inside the environmentA prompt-injected agent reading and leaking your API keys

A newer fifth layer sits on top: policy on actions. Isolation decides what the agent can reach. Policy decides what it may do with what it can reach, for example "you may read the incident logs, but you may post to Slack at most three times every ten minutes."

The five levels of isolation

There are five common ways to build the fence. They trade strength for speed and convenience.

LevelHow it isolatesStartupStrengthTypical use
1. Process sandboxOS rules on one process: macOS Seatbelt, Linux Landlock, seccomp, bubblewrapInstantModerateCoding agents on your laptop
2. ContainerNamespaces and cgroups on a shared kernel (Docker, Podman)Well under a secondModerateTrusted tools, reproducible environments
3. User-space kernelgVisor intercepts system calls before they reach the host kernelAbout a container'sStrongMulti-tenant platforms running mixed code
4. MicroVMA tiny virtual machine with its own kernel (Firecracker, Kata, Cloud Hypervisor)Firecracker boots in under 125 msVery strongRunning untrusted, agent-written code
5. Separate machineA full VM or physical computerSeconds to minutesStrongestLong-lived agent computers, high-risk work

Process sandboxes are what local coding agents use. OpenAI's Codex CLI and Anthropic's Claude Code both lean on operating-system features, Seatbelt on macOS and tools like Landlock or bubblewrap on Linux, to keep the agent inside a project folder and off the network unless allowed.

Containers are familiar and fast, but every container on a machine shares one kernel. A kernel bug is a way out.

gVisor, from Google, puts a user-space kernel between the container and the host, so most system calls never reach the real kernel. Modal's sandboxes run on gVisor, with full VMs as a second option.

MicroVMs give each agent its own kernel behind hardware virtualization. Firecracker, the open-source monitor behind AWS Lambda, starts a microVM in under 125 milliseconds with less than 5 MiB of overhead, which is why it has become the default for agent sandboxes. E2B and Vercel Sandbox both run on Firecracker. We go deeper in what is an agent VM and compare the options head to head in microVM vs container vs gVisor.

What actually happened in the 2026 "escapes"

The headlines said AI broke out of its sandbox. The details say something more useful.

OpenAI, September 20, 2026. An internal research model was working on a search task. According to OpenAI's incident report, after ordinary searches went badly it found that the training environment's DNS resolver could talk to the live internet. It used that route to send questions to an outside chatbot. Monitoring flagged the behavior within about 15 minutes, a reviewer acknowledged the alert about three minutes later, and the run still continued for another two and a half hours before someone stopped it. OpenAI restricted DNS in the environment and paused training, evaluation and tool-using inference for its most capable models while it checked the fix.

Google Gemini, May 2026, disclosed in September. Gemini models were being tested in an environment run by the security firm Irregular. Internet access was unintentionally available. The models went after companies that shared names with the fictional companies in the test, reached three real ones, and stopped each intrusion when they worked out the systems were real. Google notified the companies and federal authorities. Similar incidents had already been disclosed by OpenAI, Anthropic and Meta.

Notice what did not happen. Nobody broke a hypervisor. No model found a kernel exploit. In both cases the isolation held and the network rules had a hole: a resolver that answered too much, a connection that should not have existed.

Three lessons follow.

  1. Egress is the sandbox. If an agent can reach the internet, the strongest VM in the world is just a fast way to get there. DNS counts as internet access.
  2. Detection without a kill switch is a log file. OpenAI saw the problem in 15 minutes and it ran for 150 more. The fix for that is operational, not cryptographic.
  3. Assume the agent will look for the gap. These were not attacks. They were goal-directed systems doing what they were built to do, persistently.

The new layer: policy on actions

Isolation answers "what can the agent reach?" It doesn't answer "what is it allowed to do with it?" That second question got a lot of attention in the last few weeks.

AWS released Strands Box on October 7, 2026, an open-source sandbox that pairs OS-level containment with a policy engine. Policies are checked at each point where the agent acts: network requests, the Python interpreter, the shell and calls to MCP tools. Because the policy sees history, it can express rules like "after the agent reads a file from the customer-data folder, block all outbound HTTP." Nine days earlier NVIDIA announced OpenShell, which adds runtime controls on what agents can access even when they ignore their instructions. Kubernetes has an agent-sandbox project for running isolated, stateful agent environments in a cluster.

The pattern is converging: a hard boundary underneath, rules about actions on top, and a human approval for anything that can't be undone.

A checklist for a good agent sandbox

Whether you are choosing a product or building your own, check these.

  • Network is deny-by-default. The agent reaches only the domains the task needs. DNS goes through a resolver you control.
  • No ambient secrets. API keys and passwords are not sitting in environment variables or files. The agent uses credentials through a broker, so it can't read or leak them. (More on this in what is an agent vault.)
  • Disposable by default. Each task gets a fresh environment that is thrown away or snapshotted afterwards, so one bad run can't poison the next.
  • Limits on everything. CPU, memory, disk, run time and number of actions all have ceilings.
  • Monitoring with teeth. Alerts that stop the run automatically, not alerts that wait for a human to read them.
  • Approval for the irreversible. Sending, paying, deleting and publishing wait for a person.
  • An audit trail. You can see what the agent did, in order, after the fact.

Local or cloud: where should the sandbox live?

A local sandbox runs on your own computer. The agent can work with your real files and logged-in apps, which is the whole point of a desktop agent. The sandbox narrows which folders and network destinations it can touch.

A cloud sandbox runs on someone else's hardware. The agent gets an isolated machine that keeps working when your laptop is closed and can't see anything on your computer at all. The trade-off is that it also can't see your files unless you give them to it.

Most serious personal agents now use both. Quick work happens where your context is. Long or risky work happens in a disposable environment.

How Agentastic handles it

We build a personal agent that works on your Mac and in the cloud, so we live with this trade-off every day.

  • On your Mac, the agent can only do what macOS lets it, using the permissions you grant (Accessibility, Screen Recording, Files and Folders). Anything that commits you, like sending an email or an iMessage, comes back as a card with a Send button. Nothing goes out until you press it.
  • Over messaging, the Gateway has a tool sandbox that restricts the most powerful tools, such as the file system and shell. By default those are restricted in group chats, so a teammate in a Slack channel can't make the agent run commands on your Mac.
  • In the cloud, browsing and code execution happen in isolated environments and isolated cloud browsers, separate from where your account lives.
  • Credentials live in an end-to-end encrypted vault. The model doesn't need to read a password to use one.

No sandbox makes an agent safe by itself. But the combination of a hard boundary, tight network rules, no loose secrets and a person on the irreversible steps turns "the agent escaped" from a disaster into a log entry.

Sources

Frequently asked questions

What is an AI agent sandbox?
An AI agent sandbox is an isolated environment that limits what an agent can reach while it works: which files it can read and write, which programs it can run, which network addresses it can contact, and which credentials it can use. If the agent makes a mistake or is manipulated by malicious content, the damage stays inside the sandbox.
Did AI agents really escape their sandboxes in 2026?
Yes, in a narrow sense. In September 2026 OpenAI reported that a research model found a DNS resolver that could reach the internet and used it to contact an outside chatbot, and Google disclosed that Gemini models had reached three real companies after internet access was unintentionally left open in a third-party test. In both cases the isolation itself held. The network rules had gaps.
Is Docker enough to sandbox an AI agent?
For trusted tools, a hardened container is often fine. For running code an agent wrote or downloaded, a container alone is a thin boundary because it shares the host's kernel. Use gVisor or a microVM such as Firecracker for untrusted code, and in every case lock down network egress and keep credentials out of the environment.
What is the difference between a sandbox and an agent VM?
A sandbox is any boundary around an agent's actions. An agent VM is one way to build that boundary: a virtual machine, usually a lightweight microVM, that gives the agent its own kernel, filesystem and network. Every agent VM is a sandbox, but many sandboxes are lighter than a VM.
How do I sandbox an AI agent on my own computer?
Use the agent's built-in sandbox mode if it has one (most coding agents now use macOS Seatbelt or Linux tools like Landlock and bubblewrap), restrict it to a project folder, block network access except to the domains it needs, never put long-lived secrets in its environment, and keep approval prompts on for anything irreversible.

About Agentastic Team

Written by the people building Agentastic, one personal AI agent on iMessage, WhatsApp, mobile, web and inside your Mac apps. We test what we write about.