Overview
The rise of AI agents has transformed how we work—coding agents ship software faster, support agents resolve tickets autonomously, and research agents synthesize information across thousands of sources in minutes. But running agents at scale requires a new kind of infrastructure: the agentic cloud. Traditional cloud models, built on the one-app-serves-many-users paradigm, can’t handle tens of millions of simultaneous agent sessions. Cloudflare’s Agents Week launched a suite of tools to solve this. This guide walks you through building your own agentic cloud using Cloudflare’s primitives—from compute to storage to the agentic web. By the end, you’ll have a running prototype that deploys agents serverlessly, with persistent storage and Git integration.

Prerequisites
- A Cloudflare account (free tier works)
- Basic familiarity with Cloudflare Workers and JavaScript/TypeScript
- Node.js and npm installed locally
- Optional: a Git client (for Artifacts integration)
Step-by-Step Guide
Step 1: Setting Up Agent Compute with Sandboxes
Agents need somewhere to run. Cloudflare Sandboxes provide isolated, persistent environments—a real computer with a shell, filesystem, and background processes. For this guide, we’ll create a simple coding agent that can execute shell commands.
- Create a new Workers project:
npx wrangler init agent-sandbox - Install the Sandboxes client:
npm i @cloudflare/sandboxes - In
src/index.ts, write:
import { Sandbox } from '@cloudflare/sandboxes'; export default { async fetch(request: Request): Promise<Response> { const sbx = await Sandbox.create({ timeout: 30000 }); const result = await sbx.run('echo "Hello from agentic cloud!"'); return new Response(result.stdout); } }; - Deploy:
npx wrangler deploy
Now your agent has a temporary machine. For persistence, see Step 2.
Step 2: Adding Versioned Storage with Artifacts
Agents generate code and data. Artifacts is Cloudflare’s Git-compatible versioned storage, allowing you to create millions of repos, fork from any remote, and hand off a URL to any Git client.
- Enable Artifacts in your Cloudflare dashboard under Workers > Artifacts.
- Create a new repo programmatically in your Worker:
import { Artifacts } from '@cloudflare/artifacts'; export default { async fetch(request: Request): Promise<Response> { const repo = await Artifacts.createRepo('agent-workspace'); await repo.write('README.md', '# My Agent Project'); return new Response(`Repo: ${repo.url}`); } }; - Use the
forkmethod to clone from GitHub:await Artifacts.fork('https://github.com/example/repo.git');
Combine with Sandboxes: agents can clone their own repo, install packages, and run tests in a sandboxed environment.
Step 3: Securing Agent Identity
Agents must authenticate and be authorized. Use Cloudflare Access or Workers KV for token management. Example with API tokens:

const token = await request.headers.get('Authorization');
if (!token || token !== env.AGENT_SECRET) {
return new Response('Unauthorized', { status: 401 });
}
For fine-grained access, use Cloudflare’s Cloudflare Access service to gate Sandbox and Artifact endpoints.
Step 4: Equipping Agents with Tools and Models
Agents need model access (e.g., via Workers AI) and external tools. Integrate OpenAI’s API or Cloudflare’s Workers AI:
import { Ai } from '@cloudflare/ai';
export default {
async fetch(request: Request): Promise<Response> {
const ai = new Ai(env.AI);
const response = await ai.run('@cf/meta/llama-3-8b-instruct', {
prompt: 'Write a short story.'
});
return new Response(response.text);
}
};
Step 5: Running Agents at Scale
Deploy your agent as a Worker. Workers scale automatically to handle millions of requests. Use Durable Objects for stateful agents. Example:
import { DurableObject } from 'cloudflare:workers';
export class AgentSession extends DurableObject {
async fetch(request: Request) {
// Persistent agent logic here
}
}
Step 6: Adapting for the Agentic Web
Agents will drive traffic. Use Cloudflare’s bot management and Rate Limiting to ensure fair use. Also, serve agent-friendly endpoints (JSON, plaintext) alongside HTML.
Common Mistakes
- Not isolating agents: Multiple agents sharing a Sandbox can conflict. Always create a new sandbox per session or use Durable Objects for state isolation.
- Ignoring timeout limits: Sandboxes have a default timeout (e.g., 30s). Be sure to adjust based on agent task length.
- Hardcoding secrets: Use Cloudflare Workers secrets (env vars) instead of putting API tokens in code.
- Over-fetching data: Agents may pull large repos—use Artifacts’ selective file read to avoid memory bloat.
Summary
Building an agentic cloud with Cloudflare is straightforward: start with Sandboxes for compute, Artifacts for versioned storage, Workers AI for models, and Durable Objects for state. This stack gives you the primitives to create agents that run persistently, scale to millions, and interact with the web. The future of cloud infrastructure is agent-native—and you now have the blueprint to build it.