# Agent Sandbox

> A closed box where an agent can run code. It can't reach the real computer.

**Field:** Artificial Intelligence  
**Category:** AI Agents  
**Also known as:** AI Sandbox, Sandboxed Agent, Agent Container

## Think of it like

Think of it like a sandpit. You can dig and build all you like, but the sand stays inside.

## Definition

An agent sandbox is a closed space, like a container or a spare virtual machine, where an agent can run code without reaching the real system. Its walls set what the agent can touch: which folders, which websites and which secrets. If the agent makes a mistake or is tricked, the harm stays inside. So the agent can work with fewer stops to ask, since the worst case is small. Sandboxes and permissions work best as a pair.

## Example

Jack lets his agent install things and run any command. But it all runs in a box with a copy of the project. His keys are not in the box.

## Why it matters

Permissions only work if the agent asks. A sandbox keeps the harm small, even when a bad step gets through.

## Common mistake

Putting real secrets inside the sandbox. Whatever is inside, the agent can read and leak.

## Three principles

- **Walls around the agent.** Files, network, secrets.
- **Harm stays inside.** Even if tricked.
- **Fewer stops.** The worst case is small.

## Related terms

- [Agent Permissions](https://learn.benibix.com/term/ai/agent-permissions)
- [Computer Use](https://learn.benibix.com/term/ai/computer-use)
- [Human-in-the-Loop](https://learn.benibix.com/term/ai/human-in-the-loop)
- [Claude Code Sandbox](https://learn.benibix.com/term/ai/claude-code-sandbox)
- [Excessive Agency](https://learn.benibix.com/term/ai/excessive-agency)
- [Lethal Trifecta (AI Agents)](https://learn.benibix.com/term/ai/lethal-trifecta)
- [Code Execution Tool](https://learn.benibix.com/term/ai/code-execution-tool)

## Told apart from

- [Agent Sandbox vs Agent Permissions](https://learn.benibix.com/compare/agent-sandbox-vs-agent-permissions): People often think that if an agent has strict permissions, it does not need a sandbox. Permissions decide which actions the agent may take, and they depend on each action being checked. A sandbox limits what any action can reach, even one that slipped through. Permissions stop the wrong step. A sandbox keeps the damage small when one gets past.

![An agent inside a closed box with its own copy of the project. Arrows to the real computer, the secrets and the open internet are blocked at the walls.](https://learn.benibix.com/diagrams/ag-agent-sandbox.svg)

---

Source: https://learn.benibix.com/term/ai/agent-sandbox
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
