Cloudflare Agents

Build and deploy persistent, stateful AI agents on the Cloudflare network, with built-in support for state management, scheduling, workflows, and real-time communication.

Build and deploy persistent, stateful AI agents on the Cloudflare network, with built-in support for state management, scheduling, workflows, and real-time communication.

The gist

Cloudflare Agents is an open-source framework by Cloudflare for building and deploying persistent, stateful AI agents. Powered by Cloudflare Durable Objects, it provides execution environments for agentic workloads. Each agent manages its own state and lifecycle, with built-in support for real-time communication, scheduling, and AI model calls. This solves the challenge of creating scalable, cost-effective agents that hibernate when idle and wake on demand, ideal for running millions of instances simultaneously.

What it does

  • Provide persistent, stateful execution environments for agentic workloads.
  • Sync state automatically to all connected clients and across restarts.
  • Expose type-safe RPC methods using simple decorators.
  • Schedule one-time, recurring, and cron-based tasks for agents.
  • Build durable, multi-step workflows with human-in-the-loop approvals.
  • Manage message persistence, resumable streaming, and tool execution for AI chat.

How it works

Cloudflare Agents is an open-source SDK distributed as NPM packages. Developers define agent behavior in TypeScript classes, using decorators for callable methods and state management. These agents are deployed as Cloudflare Durable Objects, which hibernate when idle to reduce cost. A client library for environments like React allows frontends to call agent methods and receive real-time state updates. The framework is free, but usage of the underlying Cloudflare infrastructure is priced separately.

Best for

This framework is best for developers on the Cloudflare platform who need to build scalable, stateful AI applications. It excels at creating per-user or per-session agents, such as persistent chatbots, game room managers, or complex workflow orchestrators.

Watch out for

The framework is tightly integrated with the Cloudflare ecosystem, particularly Durable Objects, and is not suitable for deployment on other platforms. The SDK is evolving rapidly, and the project is not currently accepting external pull requests.