# Cloudflare Agents SDK
[[Cloudflare]] Agents SDK is a TypeScript framework for building stateful AI agents on [[Cloudflare Workers]] and [[Cloudflare Durable Objects]]. Each agent instance maps to a single Durable Object — giving it strong consistency, persistent SQLite-backed state, WebSocket support, and the ability to schedule its own future work via alarms.
The SDK is Cloudflare-specific by design: it leans on Durable Objects' per-instance addressability, Workers' V8 isolate model, and the platform's WebSocket hibernation. It is not a generic agent framework like LangChain — it is "how to write durable agents that live forever on Cloudflare's edge."
## Why It Matters
Most agent frameworks treat state as an afterthought — assume external Redis, external DB, external queue. The Agents SDK inverts this: every agent has its own SQLite database inside its Durable Object, can wake up on a schedule, and resumes exactly where it left off after restarts. For long-running agents (research, monitoring, orchestration), this changes the operational model.
Pairs naturally with [[Cloudflare Workers AI]] for inference (routed through [[Cloudflare AI Gateway]] if you want logs and spend limits), [[Cloudflare Sandbox SDK]] for code execution, [[Cloudflare Browser Rendering|Browser Run]] and [[KiteSurf]] for browsing, [[Cloudflare Artifacts]] for Git-backed files, [[Cloudflare Email Routing and Sending|Email Service]] for an inbox, and [[Cloudflare Vectorize]] for memory/RAG.
## Core Primitives
- **Agent class**: extends Durable Object, exposes RPC methods, manages state
- **State management**: typed via TypeScript generics, persisted automatically
- **Scheduled tasks**: agents can call `this.schedule(when, method)` to invoke themselves later
- **Real-time**: WebSocket support for streaming responses to clients
- **Workflows**: durable, restartable multi-step processes via [[Cloudflare Workflows]]
- **MCP servers**: ship agents as [[Model Context Protocol (MCP)|Model Context Protocol]] servers; the SDK supports the MCP 2026-07-28 specification since July 27, 2026
- **Project Think** (`@cloudflare/think`): the opinionated harness. v0.14.0 (June 2, 2026) added on-demand [[AI Agent Skills|Agent Skills]] (experimental), chat messengers starting with Telegram, declarative scheduled tasks and durable reasoning steps inside Workflows; v0.17.0 (June 26) added background sub-agents
- **Third-party harnesses**: the Pi harness runs on top of the SDK through `PiHarness` (beta, October 2, 2026), Cloudflare's first step toward hosting other teams' harnesses
- **Tracing**: agent traces for Think, [[Flue]] and AI SDK runs (August 4, 2026)
## Common Use Cases
- **Chat agents** with persistent memory across sessions
- **Voice agents** with hibernating WebSocket connections
- **Browser-automation agents** orchestrating multi-step workflows
- **Background workers** that wake up, do work, sleep — for hours, days, weeks
- **MCP servers** exposing tools to Claude and other LLM clients
## References
- Agents SDK home: https://developers.cloudflare.com/agents/
- GitHub: https://github.com/cloudflare/agents
- Changelog, Agents SDK v0.14.0 (2026-06-02): https://developers.cloudflare.com/changelog/post/2026-06-02-agents-sdk-v0.14.0/
- Changelog, background sub-agents (2026-06-26): https://developers.cloudflare.com/changelog/post/2026-06-26-agents-sdk-v0.17.0/
- Changelog, MCP 2026-07-28 support (2026-07-27): https://developers.cloudflare.com/changelog/post/2026-07-27-agents-sdk-v0.20.0-mcp-sdk-v2/
- Changelog, agent tracing (2026-08-04): https://developers.cloudflare.com/changelog/post/2026-08-04-agent-tracing/
- Changelog, Pi harness (2026-10-02): https://developers.cloudflare.com/changelog/post/2026-10-02-pi-harness/
## Related
- [[Cloudflare]]
- [[Cloudflare Workers]]
- [[Cloudflare Durable Objects]]
- [[Cloudflare Workers AI]]
- [[Cloudflare Sandbox SDK]]
- [[Cloudflare Vectorize]]
- [[Cloudflare AI Gateway]]
- [[Cloudflare Browser Rendering|Cloudflare Browser Run]]
- [[KiteSurf]]
- [[Cloudflare Artifacts]]
- [[Cloudflare Email Routing and Sending]]
- [[Cloudflare Wallets]]
- [[Model Context Protocol (MCP)]]
- [[Code Mode MCP Pattern]]
- [[AI Agent Skills]]
- [[Flue]]
- [[TypeScript]]
- [[Wrangler]]