What is a sandbox? Explained with a locked workroom for a contractor
A sandbox is a closed-off space where a program or AI agent can work freely but can't touch anything outside it. Explained with a contractor given one locked workroom instead of a master key.
- Author
Umair Mateen- Published
- Reading time
- 5 min
- Category
- AI
Anthropic now lets companies run Claude Managed Agents, including their sandboxes, on their own servers, and sandboxes come up in many recent AI agent launches. Here is what that word means.
In one sentence: A sandbox is a closed-off space on a computer where a program or AI agent can run commands and work on files, but cannot touch anything outside it unless you have allowed it.
The everyday picture
Imagine you hire a contractor to sort through a pile of paperwork. You could give them a master key to the whole office. Or you could give them one workroom.
The workroom has a locked door to the rest of the building. Inside are only the papers they need for this job. There is one phone, but every call goes through the front desk, and the front desk only connects numbers on an approved list. No master keys or bank cards are kept in the room.
Inside that room the contractor can work freely, without asking you before every step. If they make a mess, or someone tricks them, the damage stays in the room. When the job is done, the room is cleared for the next person.
The agent's commands run inside the sandbox. Anything it wants from the internet goes through a checkpoint that only lets approved addresses through, and the answers come back the same way.
How it works, step by step
- You give the agent a task (you brief the contractor). The AI model decides what to do, such as running a command or editing a file.
- The commands run inside the sandbox (the work happens in the workroom). This is usually a container or a virtual machine: a separate, walled-off workspace on a computer. Anthropic's docs describe a sandbox as exactly that, an isolated workspace where the agent runs commands and works on files.
- File limits keep it in its own folder (the locked door). Rules enforced by the operating system or the container block the agent from changing files outside the folders it was given.
- Network limits control what it can reach (the front desk on the phone line). Requests to the internet pass through a checkpoint, called a proxy, that only lets approved web addresses through.
- The results come back, and the space is thrown away (the room is cleared). Many services start a fresh sandbox for each session, so nothing carries over by accident.
Try it · Spot the weak point
Where is this agent's workroom weakest?
A company runs its AI coding agent in a sandbox set up like this. Which part is the weak point?
Where the picture stops
- A real workroom has solid walls. A sandbox is only as strong as how it was set up. Anthropic's Claude Code docs say its shell sandbox is not a complete isolation boundary, and that some tools run outside it.
- The locked door and the phone rule need each other. Anthropic's engineers explain that without network limits, a tricked agent could send out secret files, and without file limits it could escape and get network access.
- A contractor brings their own judgement into the room. An AI agent's "thinking" often happens elsewhere: with hosted agent services, the conversation and tool results are still sent to the AI model provider.
Try it · Myth or fact
Sandboxes: myth or fact?
Decide for yourself first, then tap each statement to check it.
0 of 4 checked
Why it matters for your business
- Less risk from mistakes and tricks. If an agent is fooled by hidden instructions in a web page or email, a sandbox limits what it can damage or send out.
- Fewer interruptions. Inside agreed limits, the agent can work without asking before every action. Anthropic reported that sandboxing cut permission prompts by 84% in its own internal use of Claude Code.
- Safer secrets. Keeping passwords and API keys out of the sandbox means a compromised agent has nothing valuable to take.
- Clearer choices. When a vendor says "sandboxed", you can ask who runs the sandbox, what it can reach and what is kept out of it.
An example
Imagine a 20-person accounting firm that wants an AI agent to tidy up spreadsheets each night. Instead of running it on a staff laptop, they run it in a fresh container that holds copies of that day's files. The container can reach only the firm's file storage, with no other internet access, and holds no bank logins. If a spreadsheet contained hidden instructions telling the agent to email client data out, the request would hit the closed door and go nowhere.
Frequently asked questions
Is a sandbox the same as a virtual machine?
Not exactly. A virtual machine is one way to build a sandbox. Others use containers, or features built into the operating system, such as bubblewrap on Linux or Seatbelt on macOS.
Does a sandbox make an AI agent completely safe?
No. It limits the damage, but it depends on good settings, and anything you place inside it, like a password, can still be misused. Approvals and monitoring are still worth having.
Where does the word come from?
From a child's sandbox: a closed-off area where you can play and make a mess without affecting the rest of the garden. Security experts have used it for decades for running untrusted programs safely.
What is a self-hosted sandbox?
It means the sandbox runs on your own servers or cloud account, so the agent's files and commands stay with you. You then also have to secure, update and watch it yourself.
Related explainers
- What is an AI agent? Explained with an assistant you send on errands
- What is prompt injection? Explained with a forged note in the in-tray
- What is tool use in AI? Explained with a calculator in an exam
- What is role-based access? Explained with office keycards
The DevDrift sets up AI agents with sandboxing, approvals and audit trails: see how.
Sources
Could you explain this to a colleague now?
Mark it and posts that mention it will show a tick. Saved in this browser only.