All courses

Sandboxes and isolated environments

Explain how running the agent in a container, VM, dev container or cloud sandbox limits what a mistake can damage. Explain why this is the condition under which more autonomy becomes reasonable.

Builds on: Approvals and permission modes, Terminal, IDE and cloud agents

Read it card by card Start the whole course

Tired of clicking 'approve'

In the last hour your agent has asked for approval about 30 times: `ls`, `npm install` (which downloads code the project uses), running a script. You want to switch on auto-approve on your laptop. Then it could work through a bigger task while you get coffee. Before you do: if one of its commands is wrong, what exactly could it damage?

The agent acts with your powers

A terminal agent's commands run as *you*. Anything your user account can do, they can do. They can delete files anywhere in your home folder, read saved credentials (passwords, keys and login tokens), reach servers you're signed into, and install software. Approvals are a fence you guard by hand, and auto-approve removes that fence. A **sandbox** moves the fence instead. The agent runs in a walled-off space that holds only what you deliberately put in.

Kinds of sandbox, and what to check

Common forms: - **container**: an isolated space on your computer, e.g. Docker - **VM**: a whole simulated computer - **dev container**: a container defined by the project, opened by your IDE - **cloud sandbox**: a remote machine, used by cloud agents Check four things: 1. **Files**: only the project. 2. **Credentials**: none of yours, apart from the agent's own login. Some tools copy your logins in automatically, so look. 3. **Network**: only what the task needs. 4. **Disposable**: you can delete it and rebuild it.

Auto-approve inside the box

You open the project in a dev container. Apart from the agent's own login, it holds no credentials. Its network reaches only the AI service the agent runs on and the site `npm install` downloads from. You turn on auto-approve, and a wrong `rm -rf` runs. Outside the project there is nothing of yours to lose, so you just rebuild the container. Catch: the project folder is usually **shared** with your laptop, so deletions there are real. Keep a copy of the project somewhere the container can't reach, and still check the result.

Same mistake, two places

One mistaken command, run with auto-approve on. What it can reach depends entirely on where the agent runs.
# Same mistaken command, auto-approve on
⚙ Run: rm -rf ~/old-projects

On your laptop:
  ~ is your real home folder
  ~/old-projects and its contents are gone

In a dev container (no real files inside):
  ~ is the container's own home
  it holds nothing of yours to delete
  your laptop is untouched

Shrink the damage, then loosen the reins

Approvals limit what the agent *does*. A sandbox limits what a mistake can *reach*. Give more autonomy only inside a box with no real credentials, limited network and nothing you can't throw away. Even then, check what comes out of it.

On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.