What is an agent sandbox?
An agent sandbox is an isolated execution environment, such as a container or virtual machine with restricted file system and network access, inside which an AI agent can run code and tools without reaching anything outside its limits.
An agent that runs code, edits files or browses the web will eventually do something no one intended, whether through a model mistake, a misread instruction or a prompt injection. Asking a person to approve every step does not scale and, as approval counts rise, stops being careful.
A sandbox takes a different approach: decide in advance what the agent can reach, enforce it outside the model, and let the agent work freely inside those limits.
The two boundaries
Anthropic's October 2025 post on Claude Code sandboxing names two boundaries that both have to hold. File system isolation means the agent can only read and modify specific directories. Network isolation means it can only connect to approved servers. Either one alone leaves a gap: without network isolation, a compromised agent can send out anything it can read, and without file system isolation, it can tamper with the system it runs on.
Internally, Anthropic found sandboxing cut permission prompts by 84%, because actions inside the boundary no longer needed a person to approve them.
Beyond the container
Credentials outside
Anthropic's containment guidance keeps secrets in a vault or proxy so generated code never holds them: credentials that never enter the sandbox cannot be exfiltrated.
Allowlists as capability grants
Every function reachable through an allowed domain is attack surface, so network allowlists are kept as short as the task permits.
Brain separate from hands
Anthropic's Managed Agents design separates the model and harness from the sandboxes where tools run, so a failed container becomes a retryable tool error rather than a lost session.
Disposable environments
A fresh sandbox per task or session limits how long anything planted by an attack can persist.
What a sandbox does not cover
A sandbox limits reach, not judgement. Data the agent is allowed to see can still be misused through channels it is allowed to use, and a sandbox says nothing about whether an answer is correct or on-policy. That is why sandboxes are paired with guardrails, approvals for high-risk actions and evals.
How Motiontic's engineers apply it
Motiontic's engineers define the sandbox from the task: which directories, which hosts, which credentials through which proxy. The boundary is written down before the agent's tools are built, and tested with eval cases that try to reach outside it.
Three ways to control what an agent does
| Permission prompts | Classifier-gated auto mode | Sandbox | |
|---|---|---|---|
| Who decides | A person, per action | A model classifier, per action | A boundary set in advance |
| Nature | Procedural | Probabilistic | Deterministic |
| Known weakness | Approval fatigue | Misses: Anthropic publishes a 17% miss rate on overeager actions | Allowed channels remain attack surface |
| Fits | Rare, high-impact actions | Routine actions in a trusted setup | Any agent that runs code or tools |
Common questions
What is an AI agent sandbox?
An agent sandbox is an isolated environment, usually a container or virtual machine with file system and network limits, where an AI agent can run code and tools without reaching anything outside an approved boundary.
Why do AI agents need sandboxes?
Because model-level defences are probabilistic and will sometimes fail. A sandbox caps the damage of a mistake or a prompt injection, whatever the model decides to do.
Is a Docker container a sandbox for an agent?
It can be the base of one, but a container alone is not enough. The agent also needs network egress limits, scoped file access and credentials kept outside the container.
Related
Blast radius (AI agents)
The worst an agent could do, measured by what it can reach.
Prompt injection
Untrusted text that hijacks a model's instructions, and how agents are built to survive it.
Approval fatigue
Too many approval prompts, and people stop reading them.
AI guardrails
Checks on what goes into a model, what comes out, and what an agent is allowed to do.
AI agent development
Agents that do real work for users, with the evals, traces and guardrails to keep them in production.
Running agents that have to hold up?
Describe the agent, the systems it touches and what it must never get wrong. The first call is with a lab engineer, who will say plainly whether it is ready for production, and whether Motiontic is the right team.