Sandboxing AI agents, 100x faster

Sandboxing AI agents, 100x faster

By @kentonvarda
Publication Date: 2026-03-24 13:00:00

We presented last September Code modethe idea that agents should perform tasks not through tool calls, but by writing code that calls APIs. We have shown that this is possible by simply converting an MCP server into a TypeScript API 81% reduction in token usage. We have shown that code mode can also work behind an MCP server instead of in front of it and creates the new one Cloudflare MCP server that exposes the entire Cloudflare API with just two tools and less than 1,000 tokens.

However, if you want an agent (or an MCP server) to run AI-generated code on the fly to perform tasks, that code must run somewhere, and that location must be safe. You can’t just eval() AI-generated code directly in your app: A malicious user could easily cause the AI ​​to introduce vulnerabilities.

You need one sandbox: A place to run code that is isolated from your application and the rest of the world, except for the specific functions you want the code to access.

Sandboxing is a hot topic in the…