Sandboxing an AI Agent
TLDR Dev 3 weeks ago
Two architectural approaches exist for running AI agents in sandboxes: keeping the agent loop on the local machine with the sandbox as a tool backend, or moving the entire agent into the sandbox as its home. The tool-backend model requires manual file transfers across the sandbox boundary but keeps API keys local, while the agent-in-box model simplifies deployment but moves secrets into the sandbox and requires more memory (4 GiB versus 1-2 GiB). Sandboxing agents provides containment against prompt injection attacks, enables parallel execution without resource conflicts, ensures reproducibility through isolated environments, enforces hard resource limits, and allows cheap recovery by discarding failed runs rather than debugging cleanup.