curiosity

Article · Agent sandboxes

What is an agent sandbox?

An agent sandbox is an isolated place where an AI agent runs the code it writes. It limits which files that code sees, whether it reaches the network, how long it runs and what it can change outside. It assumes the code may be wrong, or written by someone steering the agent.

Topic Agent sandboxes Reading time 8 min References 7 Updated October 2026

In short

An agent sandbox is an isolated environment that runs the code an AI agent writes, and limits what that code can reach. It sits between the agent and everything else: your files, your network, your systems. A permission prompt asks a person before each action. A sandbox draws the boundary once, and the agent works freely inside it.

A sandbox is not the same as a container, which is one way to build one. Nor is it a guardrail on the model. A guardrail tries to keep the model from writing harmful code. A sandbox assumes it sometimes will.

Why agents that run code need one

An AI agent that runs code runs something nobody reviewed. The model wrote it a moment ago, from a task and whatever it read along the way. A ticket, a web page or an attached file can carry instructions the model follows by mistake. Prompt injection has no filter you can rely on, so the code has to be safe to run even when the agent is steered.

NVIDIA’s glossary counts a secure runtime among the parts of an agent: “a dedicated, policy-enforced environment where an agent executes its logic, runs generated code, and interacts with external tools.”

A sandbox also saves a person’s attention. Anthropic reported that in its own use, sandboxing Claude Code cut permission prompts by 84%. Fewer prompts leave less room for approval fatigue, where a person stops reading what they approve.

How it works

Walls, and one way out

A script reaches for the disk, the network and more time. The sandbox stops each one at its wall. Pick a step to stop the drawing and read it.

An agent sandbox and its walls A script an agent wrote runs inside a sandbox. Its reads of the host disk, its call to the network and a command that never ends all stop at the sandbox wall. The one way out is a change that applies after a person approves it. SANDBOX · ONE SESSION$ cat /etc/passwdHOST DISKNo such path$ curl example.comNETWORKNo route out$ sleep 9999CLOCKStopped at the limit$ commitLIVE SYSTEMAfter a person approves
An agent sandbox and its walls A script an agent wrote runs inside a sandbox. Its reads of the host disk, its call to the network and a command that never ends all stop at the sandbox wall. The one way out is a change that applies after a person approves it. SANDBOX$ cat /etc/passwdHOST DISKNo such path$ curl example.comNETWORKNo route out$ sleep 9999CLOCKStopped$ commitLIVE SYSTEMApproved
  1. 01

    The agent writes a script

    Code a model wrote a moment ago, that nobody has reviewed: four commands.

  2. 02

    The filesystem wall

    The script sees only the paths it was given. /etc/passwd is not one of them.

  3. 03

    The network wall

    There is no route out, so nothing the script read can leave.

  4. 04

    The clock

    A command that never ends runs into the time limit and stops with an error.

  5. 05

    One way out

    What the agent changed leaves as a diff, and applies only after a person approves it.

What a sandbox has to limit

Anthropic’s engineers put the core of it in one line: “effective sandboxing requires both filesystem and network isolation.” Without the first, the code can read keys and change system files. Without the second, it can send what it read anywhere. A complete sandbox limits six things:

  • Filesystem. Which paths exist, and which of them can be written.
  • Network. None, or only hosts you named, enforced by something outside the sandbox.
  • Processes. Whether the code can start other programs, and whether the same limits hold for them.
  • Time. A wall clock per run, so a loop that never ends stops.
  • Memory and output. Bytes held and bytes printed. What a script prints is what the model reads next, so output is also a budget for its context.
  • What it can write back. The one way out. A change should leave as something a person can read and approve, not as a write to the live system.

How sandboxes are built

Five approaches are common. They differ in where the wall stands, and in what the code inside still shares with the host.

  • Containers. The code runs as a process with its own view of files and network, on the host’s kernel. A container starts fast and runs any program. A flaw in that shared kernel is a way out, which gVisor’s documentation calls a container escape.
  • gVisor. An application kernel, written in Go and run in user space, sits between the code and the host. The reason, in its documentation: system interfaces move “into a distinct, per-sandbox application kernel in order to minimize the risk of a container escape exploit.” It is slower for code that makes many system calls.
  • MicroVMs. Each sandbox gets a small virtual machine with its own kernel. Firecracker runs in user space and uses Linux KVM to create them. Its site gives a boot time under 125 ms and under 5 MiB of overhead per VM. It needs a host with KVM, and one VM per session to manage.
  • Operating system restrictions. A process limits itself with features of the kernel. Landlock lets an unprivileged process restrict its own filesystem and network access, and that of its children. Anthropic’s sandbox for Claude Code uses bubblewrap on Linux and Seatbelt on macOS. There is nothing new to run, but the code still runs on the host, with whatever the rules leave open.
  • Interpreters with a virtual filesystem. The language runs inside the host application, over files the host hands it. There is no process to escape into, and a command the interpreter never implemented does not exist. The trade is that only the commands and libraries it implements are there. Computerwelt, below, is one.

The approaches stack. A container under gVisor, or an interpreter inside a restricted process, puts a second wall behind the first.

How sandboxes go wrong

  • A blocklist instead of a boundary. A list of refused commands has to stay complete forever. A capability the sandbox never had has nothing to refuse.
  • Credentials inside. A token in the environment is a token the code can read. For Claude Code on the web, Anthropic keeps git credentials out of the sandbox, and a proxy outside attaches them to requests it has checked.
  • The network left open for convenience. A route for a package download is also a route out for data.
  • Limits that stop quietly. A run cut short that returns what it had looks like a whole answer to the model. A limit should raise an error the model can see.
  • Writes that apply themselves. If the code can change the live system directly, the sandbox protects the host but not your data.
  • Shared sessions. Two users in one sandbox can read each other’s files and edits.

How to evaluate an agent sandbox

Ask these of any agent that runs code, ours included:

  • What can the code reach that you did not hand it?
  • Is the network off, or limited to hosts you named by something outside the sandbox?
  • Where do the credentials live?
  • Can the code start a process, and do the limits follow it?
  • What happens at a limit: an error, or a quiet stop?
  • How does a change leave: as a direct write, or as a diff a person approves, bound to exactly what they read?
  • Is each session separate from every other?

Sudo’s sandbox

His edits on top, your workspace underneath

Sudo’s session stores only what he changed, and a person approves the staged commit. Pick a step to stop the drawing and read it.

A session overlay and a staged commit Three layers. The live workspace at the bottom holds three files. Sudo edits one, and the edit lives only in the session overlay above it. He builds it, and commit stages a snapshot of the diff on top. When a person approves it, the live file becomes version 2. STAGED COMMITWhat you reviewlookup.csNOTHINGrisk.csNOTHING STAGEDrisk.csSTAGEDrisk.csAPPROVEDtriage.csNOTHINGSESSION OVERLAYOnly the changeslookup.csNOTHINGrisk.csNOTHINGrisk.csEDITEDrisk.csBUILDStriage.csNOTHINGLIVE WORKSPACERead every commandlookup.csUNCHANGEDrisk.csVERSION 1risk.csVERSION 2triage.csUNCHANGED
A session overlay and a staged commit Three layers of one file. The live workspace at the bottom. Sudo’s edit lives only in the session overlay above it. He builds it, and commit stages a snapshot of the diff on top. When a person approves it, the live file becomes version 2. STAGED COMMITWhat you reviewrisk.csNOTHING STAGEDrisk.csSTAGEDrisk.csAPPROVEDSESSION OVERLAYOnly the changesrisk.csNOTHINGrisk.csEDITEDrisk.csBUILDSLIVE WORKSPACERead every commandrisk.csVERSION 1risk.csVERSION 2
  1. 01

    The live workspace

    The configuration, as files. The session reads it again before every command.

  2. 02

    Sudo edits a file

    The edit goes into the session overlay. The live file is untouched.

  3. 03

    He builds it

    build compiles the changed file against the workspace as the change would leave it.

  4. 04

    commit stages a snapshot

    The exact diff waits for review. Nothing has been applied.

  5. 05

    A person approves

    Only then does the change reach the live workspace, as one entry in its history.

How Curiosity builds one

Sudo, the admin assistant in Curiosity Studio, works in a sandbox built on Computerwelt. It is a bash and a Python interpreter that run inside the server’s own process, over a virtual filesystem. The files in it are the workspace configuration: endpoints, AI tools, agents and schemas, as the export writes them.

Nothing is forked or executed. curl, wget, ssh and git are absent, not refused. The one exception is a headless browser, off until an administrator allows named hosts. The only paths are the mounts the session was given. The graph is read only, as the administrator in the chat.

The session keeps an overlay of what Sudo wrote or deleted, and reads everything else from the live workspace before every command. build compiles each changed file. commit stages a snapshot of the diff and stops. A person approves it, and the approval is bound to the commit they were shown.

The same machinery is open to your own assistants: a sandbox is an AI tool whose code returns an ISandbox. A script gets 60 s and 256 KB of output by default, and 300 s and 4 MB at most. Python imports a short, closed list of modules, and there is no process to run a binary in. The sandbox page shows a session, and the paper Inside Sudo covers what an approval binds.

FAQ

Questions people ask

Is a container a sandbox for an AI agent?

It is one way to build one. A container gives the code its own view of files and network, but it runs on the host’s kernel. gVisor and microVMs put another wall between the code and that kernel. Whichever you use, also limit the network, the time and what the code can write back.

Why does an agent sandbox need to block the network?

Without it, anything the code read can leave, and a steered agent can send your data to whoever steered it. Block the network entirely, or allow only hosts you name, enforced from outside the sandbox.

Can Sudo reach the internet from his sandbox?

No. The sandbox ships no network commands: curl, wget, ssh and git are absent rather than refused. One exception is off until an administrator turns it on: a headless browser that reaches only the hosts they allow.

What limits does a sandbox in Curiosity Studio have?

A sandbox you build as an AI tool gets 60 s and 256 KB of output per script by default, and 300 s and 4 MB at most. It has no process and no disk, only the mounts you define, and no network unless you name a host for the browser.

Your data. Your infrastructure.

Ask Sudo. Approve what gets built.