← Back to blog
Admin 10 min read

Cloudflare Agents SDK Hits 500K Weekly Downloads

Milestone

500K Weekly Downloads. Zero Cold Starts.

The Cloudflare Agents SDK passed half a million weekly npm downloads. Here is why developers are building stateful AI agents on Workers instead of spinning up Python servers.

TL;DR — What is the Agents SDK?

What A TypeScript framework built on Durable Objects for building stateful, persistent AI agents that run on Cloudflare Workers.
Scale 500K+ weekly npm downloads, 8.3M total downloads, v0.9.0 — the `agents` package on npm.
Why it matters Zero cold starts, persistent SQLite per agent, resumable streaming, built-in scheduling, MCP support, and React hooks — all on the edge.
Try it Three commands: `npm create cloudflare@latest -- --template agents`. Manage the underlying D1 databases with MyD1.

Half a million developers every week are choosing a TypeScript-first, edge-native framework over traditional Python agent stacks — and that tells you where AI infrastructure is headed.

The Cloudflare Agents SDK hit 500,000 weekly downloads on npm. Not 500K total — 500K every single week, with 8.3 million total downloads since launch. The `agents` package (currently v0.9.0) is growing faster than most established frameworks, and it is doing it with a fundamentally different architecture.

Instead of running agents on long-lived servers that burn memory and money while idle, the Agents SDK runs each agent as a Durable Object on Cloudflare's edge network. That means zero cold starts, automatic proximity routing to the nearest data center, and hibernation when idle — you only pay for actual compute.

500K+ Weekly npm downloads
8.3M Total downloads
0 ms Cold start time

What Makes the Agents SDK Different

Most AI agent frameworks — LangChain, CrewAI, AutoGen — are Python libraries designed to run on traditional servers. They assume you have a long-running process, a database connection, and a server that stays on 24/7. The Agents SDK takes the opposite approach: every agent is a Durable Object with its own persistent state, its own SQLite database, and its own lifecycle.

Key Features What you get out of the box
  • Persistent SQLite per agent — every agent instance has its own embedded SQLite database via the Durable Object storage API. Conversation history, tool results, and custom state survive restarts.
  • Zero cold starts — Durable Objects use hibernation. Your agent wakes instantly on the next request, with full state intact.
  • Resumable streaming — if a client disconnects mid-stream, the agent keeps running. The client can reconnect and pick up exactly where it left off.
  • Multi-model support — works with Workers AI, OpenAI, Anthropic, Google Gemini, and any OpenAI-compatible endpoint.
  • 3 tool types — define tools the agent can call, tools the human can confirm, and tools that run automatically on a schedule.
  • Built-in scheduling — agents can schedule future tasks using cron-like syntax or one-off timestamps, without external job queues.
  • MCP support — connect to any Model Context Protocol server for tool discovery and execution.
  • React hooks — the SDK ships `useAgent` and `useAgentChat` hooks for real-time bidirectional communication over WebSockets.
  • Callable RPC — expose typed methods on your agent and call them directly from your Worker, no REST endpoints needed.

How Agents Run on Cloudflare's Edge

The architecture is what sets this apart from every other agent framework. When a user connects to your agent, Cloudflare routes the request to the nearest edge location (out of 335+ data centers). The Durable Object that holds your agent's state is created in the region closest to the user — this is called proximity routing.

Once the Durable Object is active, it has:

  • A single-threaded execution context — no race conditions, no locks, no distributed state bugs.
  • Persistent storage — key-value pairs and a full SQLite database that survive across requests.
  • WebSocket support — the agent can hold open connections with clients for real-time streaming.
  • Hibernation — when no requests are active, the Durable Object hibernates. You stop paying. When the next request arrives, it wakes up with all state intact in milliseconds.

This is fundamentally different from running an agent on EC2 or a Kubernetes pod, where you pay for idle time and need to manage scaling yourself. AWS charges you whether your agent is thinking or sleeping.

Quick Start: 3 Commands

Getting a working agent deployed takes less than two minutes:

npm create cloudflare@latest -- --template agents
cd my-agents-project
npx wrangler deploy

That gives you a deployed agent with WebSocket support, state management, and a React frontend. No Docker, no infrastructure config, no database provisioning.

Code Example: A Minimal Agent

Code The simplest possible agent

Extend the `Agent` class, define your `onMessage` handler, and you have a stateful agent:

import { Agent } from "agents";

export class MyAgent extends Agent {
  // Called on every incoming message
  async onMessage(message: string) {
    // Access persistent state
    const count = (this.state.count || 0) + 1;
    this.setState({ count });

    // Reply to the client
    this.send(JSON.stringify({
      reply: "Message received",
      totalMessages: count
    }));
  }
}

The `this.state` object is automatically persisted to the Durable Object's storage. No database setup, no ORM, no migration files.

Code Example: AI Chat Agent

Code An agent that calls an LLM with tool use

The `AIChatAgent` class extends `Agent` with built-in support for multi-turn conversations, tool calling, and streaming responses:

import { AIChatAgent } from "agents/ai-chat-agent";
import { createOpenAI } from "@ai-sdk/openai";

export class ChatBot extends AIChatAgent {
  async onChatMessage(onFinish) {
    const openai = createOpenAI({
      apiKey: this.env.OPENAI_API_KEY,
    });

    return this.streamText({
      model: openai("gpt-4o"),
      system: "You are a helpful assistant.",
      messages: this.messages,
      tools: {
        getWeather: {
          description: "Get weather for a city",
          parameters: { city: { type: "string" } },
          execute: async ({ city }) => {
            return { temp: 22, condition: "sunny", city };
          },
        },
      },
      onFinish,
    });
  }
}

Conversation history is automatically persisted. If the user closes their browser and comes back, the full thread is still there.

Code Example: React Client

Code Connect your React app with one hook

The SDK ships React hooks that handle WebSocket connections, reconnection, and state synchronization:

import { useAgentChat } from "agents/react";

function Chat() {
  const { messages, input, handleInputChange, handleSubmit }
    = useAgentChat({ agent: "chat-bot" });

  return (
    <div>
      {messages.map((m) => (
        <div key={m.id}>
          <strong>{m.role}:</strong> {m.content}
        </div>
      ))}
      <form onSubmit={handleSubmit}>
        <input value={input} onChange={handleInputChange} />
        <button type="submit">Send</button>
      </form>
    </div>
  );
}

The `useAgentChat` hook manages the WebSocket connection, streams tokens in real time, and automatically reconnects if the connection drops — resuming exactly where it left off.

Agents SDK vs. Traditional Frameworks

The comparison is not Python-vs-TypeScript. It is stateless-vs-stateful, server-vs-edge, always-on-vs-hibernation.

Comparison Agents SDK vs. LangChain vs. CrewAI
Feature Agents SDK LangChain CrewAI
Language TypeScript Python / TS Python
Runtime Edge (Durable Objects) Server (any) Server (any)
State persistence Built-in SQLite External DB required External DB required
Cold starts 0 ms (hibernation) Seconds (container) Seconds (container)
Scaling Automatic (per-agent) Manual (k8s / ECS) Manual
WebSocket streaming Built-in + resumable Via callback Via callback
Scheduling Built-in (cron + one-off) External (Celery, etc.) Not built-in
React hooks Yes (first-party) Community No
Cost when idle $0 (hibernation) Server cost Server cost
Coming from LangChain?

The migration is straightforward. The biggest differences:

  • No chains or runnables — your agent is a class with methods. Call `this.streamText()` instead of piping through a chain.
  • State is built in — no need for external memory stores (Redis, Pinecone). The Durable Object persists state automatically.
  • Tools are plain objects — define a `description`, `parameters`, and an `execute` function. No `@tool` decorators.
  • Deployment is one command — `npx wrangler deploy`. No Docker, no Kubernetes, no Terraform.

The Full Cloudflare Agent Stack

The Agents SDK does not exist in isolation. It plugs into a complete serverless AI stack that Cloudflare has been building for years:

Agents SDK Stateful agent framework. Durable Objects, WebSockets, scheduling, tools.
D1 Serverless SQLite at the edge. Global distribution, automatic replication.
Workers AI GPU inference on the edge. Run models like Kimi K2.5, Llama, Mistral without provisioning GPUs.
Workers The runtime. V8 isolates, 0 ms cold starts, 335+ locations worldwide.
Workflows Multi-step durable execution. Retries, timeouts, and human-in-the-loop approvals.
Vectorize Vector database for RAG. Store embeddings alongside your agents.

The key insight: all of these run on the same edge network. Your agent (Durable Object) can query D1 (SQLite), call Workers AI (LLM inference), trigger a Workflow (multi-step task), and search Vectorize (embeddings) — all without leaving Cloudflare's network. No cross-cloud latency, no API gateway hops, no egress fees.

Why 500K Developers Chose This

The adoption numbers are not accidental. Three things are driving it:

Adoption What developers are telling us

1. Cost. Traditional agent deployments require always-on servers. A single agent instance on a t3.medium EC2 costs roughly $30/month whether it is processing requests or idle. With Durable Objects, you pay per request and per millisecond of compute. An agent that handles 100 conversations per day might cost pennies. See the full cost comparison.

2. No infrastructure. No Docker. No Kubernetes. No Terraform. No database provisioning. No connection pooling. `npx wrangler deploy` and your agent is live in 335+ locations. For teams that want to ship AI features fast, this is the difference between a weekend project and a six-week infrastructure sprint.

3. TypeScript-first. The majority of web developers write TypeScript. Making them switch to Python for AI agent work creates friction, separate toolchains, separate deployments, and separate expertise. The Agents SDK lets frontend and backend teams use the same language, the same package manager, and the same deployment pipeline.

Managing Agent Data with MyD1

Agents built on the Cloudflare stack often use D1 for shared, queryable data — user profiles, conversation logs, analytics, tool outputs. The Durable Object's built-in SQLite is great for per-agent state, but when you need to query across agents or share data between services, D1 is the answer.

That is where MyD1 comes in. Instead of writing raw SQL in a terminal to inspect your agent's data, MyD1 gives you a native macOS interface to browse tables, run queries with autocomplete, and edit data inline. And MyD1's AI Agent helps you go further — ask it questions in plain English like "show me the 10 longest agent conversations this week" and it writes the SQL, optimizes the query, and surfaces insights you would never find without AI. Download MyD1 free.

What Is Next for the Agents SDK

The SDK is at v0.9.0, which means a 1.0 stable release is coming. Based on the public docs and Cloudflare's track record, expect:

  • More model integrations — Workers AI already supports dozens of models including Kimi K2.5 and Llama 4, and the list grows monthly.
  • Dynamic Workers — agents that can spawn and manage other Workers programmatically, enabling agent-to-agent coordination.
  • Deeper MCP integration — the Model Context Protocol is becoming the standard for tool interoperability, and Cloudflare is investing heavily in it.

Get started in 2 minutes

Run `npm create cloudflare@latest -- --template agents` to scaffold a full agent project with React frontend, WebSocket streaming, and state management. Deploy with `npx wrangler deploy`. Manage your D1 databases visually with MyD1. Read the full Agents SDK docs.

Related: EC2 vs Cloudflare Workers — Full Cost Comparison · Build a Full-Stack App on Cloudflare for Free · SQLite Can Handle Your Website · Why AWS Is So Slow