Cloudflare Agents SDK
Build and deploy persistent, stateful AI agents on Cloudflare's global network using TypeScript — with built-in memory, scheduling, MCP support, durable workflows, and real-time WebSocket communication.
About Cloudflare Agents SDK
Cloudflare Agents SDK is an open source TypeScript framework for building and deploying persistent, stateful AI agents on Cloudflare's global edge network. Unlike traditional stateless AI applications that forget everything after each request, the Agents SDK gives developers a full execution environment where each agent maintains its own memory, schedule, tools, and real-time connections — all packaged as a TypeScript class.
Each agent runs on a Cloudflare Durable Object, a stateful micro-server with its own SQL database, WebSocket connections, and scheduling engine. Developers can deploy once and scale to tens of millions of agent instances across Cloudflare's global infrastructure. Agents hibernate when idle and consume no resources, then wake on demand — making them cost-efficient at any scale.
The SDK supports any AI model provider including Workers AI, OpenAI, Anthropic, and Google Gemini. With the v0.14.0 release (June 2026), the SDK added experimental Agent Skills for on-demand capability catalogs, chat messengers starting with Telegram, declarative scheduled tasks with timezone awareness, durable reasoning steps inside Workflows via ThinkWorkflow, and major production hardening for durable chat recovery across deploys and evictions.
The Cloudflare Agents SDK integrates tightly with the broader Cloudflare developer platform including Workers, AI Gateway, Vectorize (vector database), and Workflows — enabling developers to build complete AI-native applications without managing any external infrastructure.
Key Features
- Persistent Durable State: Every agent has a built-in SQL database and key-value state store that survives restarts, deploys, and hibernation, with real-time sync to all connected clients.
- AI Chat with Resumable Streams: The AIChatAgent class provides automatic message persistence, resumable streaming across disconnects, and server and client side tool execution with React hook integration.
- Model Context Protocol (MCP) Support: Agents can act as MCP servers or connect as MCP clients, exposing tools to other agents and LLMs with resumable SSE streams and readable server IDs.
- Agent Skills (Experimental): A catalog system that adds on-demand instructions, resources, and scripts to an agent's system prompt — so the model activates a skill only when a task matches, avoiding prompt bloat.
- Declarative Scheduled Tasks: Define recurring, timezone-aware prompts and handlers using a typed DSL; the SDK reconciles declarations on startup and re-arms after each run with durable idempotent submissions.
- Durable Workflows with Think Steps: ThinkWorkflow and step.prompt() enable model-driven reasoning inside Cloudflare Workflows, supporting long waits, typed structured output via Zod schemas, and human approval gates.
Pricing
Cloudflare Agents SDK is open source and free to use under the MIT license. Deployment costs are determined by Cloudflare Workers and Durable Objects usage, which follows Cloudflare's standard Workers pricing tiers:
-
Free (Workers Free Plan): $0/mo Includes 100,000 Worker requests per day and limited Durable Object compute; suitable for development and low-traffic agents.
-
Workers Paid Plan: $5/mo (plus usage) Includes 10 million requests per month, extended Durable Object compute and storage (charged per GB-second and per million requests), and access to production-grade features for deployed agents.
Full pricing details for Durable Objects, Workers AI, and Vectorize are available at cloudflare.com/plans.
Use Cases
- Building persistent AI chat assistants with durable message history and resumable streaming
- Deploying autonomous AI agents that act on schedules (daily digests, weekly reports, cron-based workflows)
- Creating per-user or per-session stateful agents that scale to millions of instances
- Connecting agents to external platforms via Telegram messengers or MCP servers
- Orchestrating multi-step human-in-the-loop approval workflows using ThinkWorkflow and Cloudflare Workflows
Pros & Cons
Pros:
- Agents are backed by Durable Objects, giving each instance isolated persistent state, SQL storage, and scheduling without external databases
- Open source MIT licensed with 4,500+ GitHub stars and active Cloudflare-maintained development
- Supports any AI model provider (Workers AI, OpenAI, Anthropic, Gemini) with no vendor lock-in
- Agents hibernate when idle, meaning millions of inactive agents cost nothing
- v0.14.0 production hardening ensures chat turns survive deploys, evictions, and stalled model streams reliably
Cons:
- Agent Skills and several advanced features are still experimental with APIs subject to change
- External pull requests are not currently accepted; community contribution is limited to issues and discussions
- Durable Objects pricing can become complex to predict at large scale with high-frequency state updates
Integrations
Cloudflare Workers, Cloudflare Durable Objects, Cloudflare Workflows, Cloudflare Workers AI, Cloudflare AI Gateway, Cloudflare Vectorize, Cloudflare Email Routing, Cloudflare R2, Telegram, OpenAI, Anthropic, Google Gemini, Hono (via hono-agents), React (useAgent / useAgentChat hooks), Model Context Protocol (MCP), Zod, Vite (Agents Vite plugin)
FAQ
What is the Cloudflare Agents SDK?
The Cloudflare Agents SDK is an open source TypeScript framework for building persistent, stateful AI agents on Cloudflare's global edge network. Each agent runs on a Durable Object with its own SQL database, scheduling, WebSocket connections, and AI model integration — packaged as a TypeScript class.
How is the Agents SDK different from a regular serverless function?
Standard serverless functions are stateless — they process a request and forget everything. Agents SDK agents maintain persistent state, memory, and schedules between requests. They hibernate when idle and wake on demand, enabling long-lived autonomous behaviors that are impossible in a standard function.
What AI model providers does the Agents SDK support?
The SDK supports any AI model provider. Built-in helpers exist for Cloudflare Workers AI, OpenAI, Anthropic, and Google Gemini. Developers can also integrate any other provider through the AI SDK's standard model interface.
What are Agent Skills?
Agent Skills (introduced as experimental in v0.14.0) are on-demand capability catalogs added to an agent's system prompt. Skills can bundle instructions, resources, and executable scripts. The model activates a skill only when a task matches, so a large library of capabilities does not bloat every prompt. Skills can be loaded from a local directory, Cloudflare R2, or a manifest.
How does durable chat recovery work?
The Agents SDK persists chat turns to Durable Object storage. If a deploy, eviction, or stalled model stream interrupts a turn, the SDK recovers it automatically. The useAgentChat React hook exposes an isRecovering flag so the UI can show a progress indicator instead of a frozen state. Sub-agents re-attach to in-flight results rather than being abandoned.
Can I schedule recurring tasks with the Agents SDK?
Yes. The SDK provides a declarative DSL for defining recurring, timezone-aware scheduled tasks. Developers specify a human-readable schedule like 'every week on monday at 09:00' along with a prompt. The SDK reconciles declarations on startup and re-arms after each run using durable idempotent submissions.
Does the Agents SDK support MCP?
Yes. Agents can act as MCP servers (exposing their tools to other agents and LLMs) or connect as MCP clients (consuming tools from external MCP servers). v0.14.0 adds resumable SSE streams so in-flight tool calls survive dropped connections, and readable server IDs so tools surface with descriptive names.
How much does it cost to run agents?
The SDK itself is free and open source. Deployment costs depend on Cloudflare's Workers and Durable Objects usage pricing. The Workers Free plan covers up to 100,000 requests per day at no cost. The Workers Paid plan starts at $5/month with additional usage-based charges for compute and storage.
How do I get started with the Agents SDK?
Run npx create-cloudflare@latest -- --template cloudflare/agents-starter, then cd into the project and run npm install followed by npm run dev. The starter includes streaming AI chat, server-side and client-side tools, human-in-the-loop approval, and task scheduling out of the box.
What is ThinkWorkflow?
ThinkWorkflow is a class introduced in v0.14.0 that enables durable model-driven reasoning steps inside Cloudflare Workflows. Using step.prompt(), developers can run AI reasoning with typed structured output (via Zod schemas), multi-day timeouts, and human approval gates — all with Cloudflare Workflows' automatic retry and durability guarantees.
Last edited
September 30, 2026 at 5:32 AM by Venkatraman Chandrasekaran
