shiichan

Cloudflare Sandboxes hits GA: give your agents a real computer!

Hey there, it's Shiichan! Today I get to tell you about giving AI agents their very own computer. So exciting!

Cloudflare Blog blog.cloudflare.com

What was announced?

Straight from Cloudflare's Blog: Cloudflare Sandboxes and Cloudflare Containers are now generally available (GA)! It was announced on April 13, 2026.

A Sandbox is an isolated compute environment made for AI agents. It comes with a shell, a filesystem, and background processes, all in one place. It starts on demand and resumes from its previous state, so you're handing your agent a real place to get its hands dirty.

The story so far

When you want an agent to write and run code, standing up a real, safe place for it to work has been surprisingly hard. You're running untrusted code, so you need isolation and you need scale. And a lot of setups even charge you for idle time while the agent waits on the LLM.

Sandboxes takes all of that off your plate. It runs on top of Cloudflare Containers, and Figma actually uses Containers for Figma Make as the foundation for running untrusted agent- and user-authored code at scale.

What changes

You can hand your agent almost the same toolbox a human developer uses.

  • Real PTY (pseudo-terminal) sessions you can drive over WebSocket
  • Stateful code interpreters for Python, JavaScript, and TypeScript
  • Spin up a dev server and check it right away through a public preview URL
  • Watch file changes so you can build a save-and-react development loop

Pricing changed too: you're no longer billed during idle time (like while the agent waits for the LLM to reply), and you only pay for the CPU you actually use. It sounds small, but it's a really nice win!

Dive Deep

The API is lovely and simple. From a Worker you grab a Sandbox, check out a Git repo, and run a command.

const sandbox = getSandbox(env.Sandbox, "agent-session-47");
await sandbox.gitCheckout("https://github.com/org/repo", {
  targetDir: "/workspace",
  depth: 1,
});
return sandbox.exec("npm", ["test"], { stream: true });

Here's the stateful code interpreter. Variables and imports persist across calls, so it works a lot like a Jupyter notebook.

const ctx = await sandbox.createCodeContext({ language: "python" });
await sandbox.runCode(pythonCode, { context: ctx });

When you want to expose a dev server, you can wait on a real readiness signal from the logs or the port before publishing, instead of guessing with a timer.

const server = await sandbox.startProcess("npm run dev", { cwd: "/workspace" });
await server.waitForLog(/Local:.*localhost:(\d+)/);
const { url } = await sandbox.exposePort(3000);

You reach the exposed server through a preview URL. There's also inotify-based filesystem watching streamed over Server-Sent Events, so you can drive event-driven loops like recompile-on-save.

The auth design is clever too. Instead of exposing credentials directly to the agent, a programmable egress proxy injects authentication at the network layer (there's a whole write-up in Sandbox auth).

Snapshots are handy as well. You can preserve a whole environment, dependencies and modified files and all, stored in R2 with tiered caching for fast restores anywhere in the world. The backup and restore guide walks you through it.

Capacity went up too: on standard pricing you get up to 15,000 concurrent lite instances, 6,000 basic, and 1,000+ of the larger ones. And since it only charges for actively used CPU cycles now, the wasteful idle billing is gone.

For the full method list, check the Sandbox API reference. To install, run npm i @cloudflare/sandbox@latest; the version at announcement was 0.8.9.

Wrap-up

  • Cloudflare's Sandboxes and Containers are now GA (April 13, 2026)
  • You can hand an agent a real dev environment: shell, PTY, stateful code interpreter, preview URLs, and file watching
  • Snapshots let you save and restore whole environments, stored in R2 plus tiered caching
  • Concurrency capacity jumped, and there's no idle billing, you only pay for CPU used
  • This one's perfect for anyone who wants agents to run code, and for developers hunting for a foundation for AI apps!