# Examples

Five small, runnable scripts. Each one shows a piece of the sandbox pattern: run
untrusted code somewhere that isn't your machine, snapshot a clean state, and let an
agent write code that only ever executes inside the box.

| file | what it teaches | run command | needs |
|---|---|---|---|
| `01_docker_sandbox.py` | Run untrusted code inside a throwaway, network-less, memory-capped Docker container. | `python 01_docker_sandbox.py` | Docker |
| `02_e2b_sandbox.py` | Same task, run in a real cloud sandbox via the e2b SDK. No Docker needed on your laptop. | `python 02_e2b_sandbox.py "print('hi')"` | `E2B_API_KEY` |
| `03_daytona_sandbox.py` | Same task again, via Daytona's remote sandbox. A second provider, same shape. | `python 03_daytona_sandbox.py "print('hi')"` | `DAYTONA_API_KEY` |
| `04_snapshot_restore.py` | Snapshot a container clean, let it get trashed, restore from the snapshot. The "snapshot it, nuke it" pattern. | `python 04_snapshot_restore.py` | Docker |
| `05_agent_in_the_box.py` | The payoff: a canned "agent" writes code, and that code runs only inside the box, never on your host. | `python 05_agent_in_the_box.py` | Docker |

All five scripts degrade gracefully. If the tool or key they need is missing, they
print exactly what they would have done and exit 0. None of them fake output.
