Lesson 10.03 · Phase 10 · Coding & Computer-Use Agents
Running code in a sandbox
An agent that runs code runs whatever the model wrote, and whatever a prompt injection convinced it to write. Contain it in layers: a throwaway directory, an allow-listed environment, a timeout that kills the whole process group, resource limits, capped output. Then be honest that this is only a guard. Isolation means a container or VM with no network and nothing mounted that you'd miss.
Learning objectives
- Run model-written code in a fresh working directory with an allow-listed environment, so host secrets never reach it.
- Enforce wall-clock, CPU and file-size limits, and kill the whole process group on timeout.
- Cap output by keeping the head and tail, and redact host paths before the model sees them.
- Explain what a process-level guard can't stop, and write the container flags that do.
Your coding agent runs the tests it just wrote. One test has while True:. Another prints a 2 GB log. A third was suggested by a README the agent read, and it does print(os.environ), which sends your OPENAIAPIKEY into the transcript and on to wherever transcripts go. A fourth starts a background server and exits, leaving a process running on your laptop for days.
Loading the full lesson…