Agent Sandbox (Sandboxed Execution)
Also called: sandboxed execution · AI sandbox · code sandbox
An agent sandbox is an isolated execution environment, such as a container, microVM, or restricted OS process, in which an AI agent runs code and commands with limited access to files, network, and credentials.
Agents that can run shell commands and write files are powerful and, if they err or are manipulated, dangerous. A sandbox limits the damage: the agent works inside a boundary where the worst case is a broken sandbox, not a wiped laptop or leaked credentials.
Sandboxes are a form of deterministic-guardrails. Rather than trusting the model to behave, the environment enforces limits, and it works even when the model has been fooled by prompt-injection.
Strength varies by mechanism. Containers share the host kernel and are lighter; microVMs and virtual machines provide a stronger boundary at more cost; OS-level sandboxes restrict a normal process. Many coding agents also combine a sandbox with permission prompts.
How it works
A sandbox typically restricts several dimensions: filesystem (only a working directory is writable), network (deny by default or allow-list hosts), resources (CPU, memory, time limits), and secrets (no ambient credentials, only scoped tokens injected when needed). The agent's tool calls execute inside, and results are returned out. Persisting state between steps, for example installed packages or a checked-out repository, is a common design choice.
Example
A coding agent is told to run a project's test suite. It runs inside a container with the repository mounted read-write, network limited to the package registry, and no access to the developer's home directory. A malicious test script that tries to read SSH keys or upload files finds nothing to take and nowhere to send it.
How it differs
Sandbox vs. permission prompts: a prompt asks a person to approve each action, which is human-in-the-loop and can suffer from approval fatigue. A sandbox limits what any approved or unapproved action can do. They are often used together.
Common misconceptions
FAQ
What is an agent sandbox?
Do coding agents need a sandbox?
What is the difference between a container and a microVM sandbox?
Last checked: 2026-09-20