Run Claude Managed Agents in a sandbox

Last updated Sep 30, 2026 runs its agent loop on the Anthropic platform. A self-managed environment runs the actions of the agent in your Cloudflare account instead. Cloudflare publishes an open-source template for that environment. Fork it, deploy it to your account, and change it as you need.

Get the template

Caution

The template is alpha software. It is not yet stable and may contain bugs.

How it works

When an agent session starts or ends, Anthropic sends a webhook to a Worker that the template deploys in your account. The Worker gives each session its own sandbox, applies an egress policy to its outbound traffic, saves the sandbox state while the session sleeps, and shuts the sandbox down when the session ends.

Each agent runs in one of two sandbox types:

  • A Linux sandbox on Containers gives the agent a shell and any process it needs to run. The template builds these sandboxes with Sandbox SDK 0.x.
  • A Dynamic Worker starts in milliseconds and costs less than a container session, but runs code in the Workers runtime without a Linux shell or processes.

For more information about the trade-offs, refer to Choose a sandbox environment.

What the template adds

The template also gives agents access to other Cloudflare products:

  • Agents reach private services over Workers VPC and Cloudflare Mesh without exposing those services to the Internet.
  • Outbound traffic passes through proxies that you configure. A proxy can add credentials to requests without the agent seeing them, restrict the domains an agent can reach, or run your own code on each request.
  • Each session can have its own email address for sending and receiving messages with Email Service.
  • Agents can use headless browsers from Browser Run to fetch pages, take screenshots, and control a browser over the Chrome DevTools Protocol.
  • Agents can generate images with Workers AI.
  • You add a tool by adding a function to one file. Tools run in the Worker with access to all of its bindings.
  • A dashboard lists agents and sessions, shows logs, and opens a shell in a running Linux sandbox.

When to use it

Use a self-managed Cloudflare environment when you need:

  • Control over the sandbox infrastructure your agents run in
  • Secure connections to private internal services
  • Custom egress policies for credential injection and domain restrictions
  • Custom tools that use Cloudflare bindings, such as R2, D1, KV, and Vectorize
  • A choice between Linux sandboxes and Dynamic Workers for each agent

Deploy the template

Follow the onboarding guide ↗︎ in the repository. It covers the Anthropic environment and webhook, secrets, D1 migrations, R2 credentials for snapshots, and dashboard security. Deploy with the Deploy to Cloudflare button, which builds the template in Workers Builds, or run npm run deploy from your terminal.

Note

You need a Workers Paid plan or an Enterprise account. The template runs Linux sandboxes on Containers, and runs Dynamic Workers and egress proxies through Worker Loader bindings.

Template documentation

The repository documents each capability:

Topic What it covers
Connecting to private services ↗︎ Reach services in other clouds, on-premises, or on your laptop with Workers VPC bindings
Applying egress policies ↗︎ Allow and deny lists, header injection, custom Worker proxies, and VPC routing
Choosing a sandbox type ↗︎ When to run an agent in a Dynamic Worker or a Linux sandbox
Agent email ↗︎ Email addresses and sending for agents
Browser tools ↗︎ Browser Run tools for agents
Adding custom tools ↗︎ Declaring new tools in src/tools/custom-tools.ts ↗︎
Customizing sandboxes ↗︎ The Dockerfile and instance_type of Linux sandboxes
Snapshots and state persistence ↗︎ How both sandbox types keep their state while a session sleeps
Architecture ↗︎ The request path from webhook to sandbox, and every binding the Worker uses
Securing access ↗︎ Securing the dashboard and API

Was this helpful?

YesNo

On this page

Run Claude Managed Agents in a sandbox - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/sandbox/coding-agents/claude-managed-agents/#page","headline":"Run Claude Managed Agents in a sandbox","description":"Run Claude Managed Agents with sandboxes on Containers and Dynamic Workers in your Cloudflare account.","url":"https://developers.cloudflare.com/sandbox/coding-agents/claude-managed-agents/","inLanguage":"en","image":"https://developers.cloudflare.com/sandbox/coding-agents/claude-managed-agents/og.png?v=1aa96be3a3075149","dateModified":"2026-09-30","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}


description: Run the Codex CLI on a GitHub repository in a Linux sandbox and read its changes as a diff. title: Run Codex in a sandbox image: https://developers.cloudflare.com/sandbox/coding-agents/codex/og.png?v=b387b053e2cfc995


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/sandbox/llms.txt
Use this file to discover all available pages before exploring further.