cloudflare / agents
Build and deploy AI Agents on Cloudflare
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing cloudflare/agents in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewCloudflare Agents Agents are persistent, stateful execution environments for agentic workloads, powered by Cloudflare Durable Objects. Each agent has its own state, storage, and lifecycle — with built-in support for real-time communication, scheduling, AI model calls, MCP, workflows, and more. Agents hibernate when idle and wake on demand. You can run millions of them — one per user, per session, per game room — each costs nothing when inactive. Or add to an existing project: **Read the docs** — getting started, API reference, guides, and more. Quick Example A counter agent with persistent state, callable methods, and real-time sync to a React frontend: State changes sync to all connected clients automatically. Call methods like they're local functions. Features | Feature | Description | | --------------------- | ---------------------------------------------------------------------- | | **Persistent State** | Syncs to all connected clients, survives restarts | | **Callable Methods** | Type-safe RPC via the decorator | | **Scheduling** | One-time, recurring, and cron-based tasks | | **WebSockets** | Real-time bidirectional communication with lifecycle hooks | | **AI Chat** | Message persistence, resumable streaming, server/client tool execution | | **MCP** | Act as MCP servers or connect as MCP clients | | **Workflows** | Durable multi-step tasks with human-in-the-loop approval | | **Email** | Receive and respond via Cloudflare Email Routing | | **Code Mode** | LLMs generate executable TypeScript instead of individual tool calls | | **SQL** | Direct SQLite queries via Durable Objects | | **React Hooks** | and for frontend integration | | **Vanilla JS Client** | for non-React environments | **Coming soon:** Realtime voice agents, web browsing (headless browser), sandboxed code execution, and multi-channel communication (SMS, messengers). Packages | Package | Description | | ------------------------------------------- | ------------------------------------------------------------------------------- | | | Core SDK — Agent class, routing, state, scheduling, MCP, email, workflows | | | Higher-level AI chat — persistent messages, resumable streaming, tool execution | | | Hono middleware for adding agents to Hono apps | | | Experimental — LLMs write executable code to orchestrate tools | Examples The directory has self-contained demos covering most SDK features — MCP servers/clients, workflows, email agents, webhooks, tic-tac-toe, resumable streaming, and more. The is the kitchen-sink showcase with everything in one UI. There are also examples using the OpenAI Agents SDK in . Run any example locally: Documentation • Full docs on developers.cloudflare.com • directory in this repo (synced upstream) • Anthropic Patterns guide — sequential, routing, parallel, orchestrator, evaluator • Human-in-the-Loop guide — approval workflows with pause/resume Repository Structure | Directory | Description | | ----------------------------------------------- | -------------------------------------------------------- | | | Core SDK | | | AI chat layer | | | Hono integration | | | Code Mode (experimental) | | | Self-contained demo apps | | | Examples using the OpenAI Agents SDK | | | In-depth pattern tutorials | | | Markdown docs synced to developers.cloudflare.com | | | Deployed websites (agents.cloudflare.com, AI playground) | | | Architecture and design decision records | | | Repo-wide tooling | Development Node 24+ required. Uses npm workspaces. Changes to need a changeset: See for deeper contributor guidance. Contributing We are not accepting external pull requests at this time — the SDK is evolving quickly and we want to keep the surface area manageable. That said, we'd love to hear from you: • **Bug reports & feature requests** — open an issue • **Questions & ideas** — start a discussion License MIT