Willison: keep the agent out, run its code in a sandbox
2026-11-18 · Simon Willison
On Nov. 17, Simon Willison described an "external sandbox" pattern he built with AI lab Prime Radiant. He says he has been exploring safer ways to sandbox agent-executed code, so people can try local models without worrying that a mistake or prompt injection will cause damaging actions on their machine.
His core idea is to separate the two: the agent itself lives outside the sandbox, and only the code it executes runs inside a dedicated sandbox. That differs from putting the whole agent in a container, so the agent's configuration and credentials need not sit in the risky environment.
Three server implementations demonstrate it: a Node.js server using v86 to run Alpine Linux in WebAssembly; a Python server running Alpine in an Apple Containers instance; and a Python server using Microsoft's Quicksand library, which bundles QEMU and Alpine. All offer the same localhost API, and Pi, Claude Code or Codex can be configured to call it when they want to run code.
The sandboxes include an optional HTTP/HTTPS allow-list proxy to control which hosts the code may contact, plus a credential replacement mechanism so authenticated API calls work without sharing a secret with the agent. Willison says he remains fascinated by the challenge of safely running untrusted code.
These are his own design and views; the post offers no independent security validation or performance data, so how well it stops prompt injection needs more testing.