Cloudflare Agents sandbox: letting agents run untrusted code in isolated Linux containers
Sandbox
The Cloudflare Agents documentation introduces the Sandbox feature, which mounts a container onto an agent's Durable Object as a Linux sandbox, allowing it to run shell commands, compile and test code, and retain files across conversation turns, for running untrusted or model-generated code in an environment away from the agent's storage and credentials. The sandbox runs in a separate virtual machine and cannot read the agent's storage, environment variables or bindings; the example sets enableInternet to false to block outbound requests, commands time out after 60 seconds, and output returns only the last 10000 characters of each stream. The documentation notes that the model reads all content returned by run_command, and that files, packages or web pages in the sandbox can print text that steers the model; tool results should be checked before the agent acts outside the sandbox, and tools with side effects should require approval; all users of the same agent instance share its sandbox. Containers require the Workers Paid plan, files disappear after stopping, and snapshots can be used to save and restore.