Packages

Cloudflare Agents SDK (`agents`): Pi 1.6 Harness, BrowserTool CDP, and MCP 2.3.1 Upgrade Guide

Technical breakdown of the Cloudflare Agents npm SDK (`agents`, 6.2K GitHub stars, MIT): claude-sonnet-5-5 default after Nov 30 retirement, non-rollback Pi 1.6 harness upgrade, persistent browserTool CDP sessions, and required @modelcontextprotocol/server@2.3.1 peer pins.

By 0xScorPionSon

8 min read

Cloudflare Agents SDK (agents): Pi 1.6 Harness, BrowserTool CDP, and MCP 2.3.1 Upgrade Guide

Cloudflare Agents SDK Pi 1.6 and MCP 2.3.1 architecture infographic

Executive Summary

The Cloudflare Agents SDK (agents on npm, cloudflare/agents on GitHub, MIT license, 6.2K GitHub stars) turns Cloudflare Durable Objects into stateful, hibernating AI agents with built-in SQLite storage, @callable() RPC methods, cron scheduling, and Model Context Protocol (MCP) endpoints. Verified as of December 3, 2026, the SDK's late-November 2026 releases (November 21–25, 2026 changelog and GitHub releases) introduce significant runtime and dependency changes that directly affect production Workers deployments.

Key changes developers must account for before upgrading:

  • Irreversible Pi 1.6 State Migration: Once a conversation runs on Pi 1.6, Pi 1.5 can no longer execute its tool calls or model requests—teams must roll forward rather than rolling back.
  • Model Retirement & Default Swap: claudeCode() now defaults to claude-sonnet-5-5 following the November 30, 2026 retirement of claude-sonnet-4-5, and examples have moved off Workers AI models retired on November 20, 2026.
  • Strict MCP Peer Pins: Subpaths agents/mcp, agents/x402, agents/mcp/server, and agents/experimental/webmcp require explicit bumps to @modelcontextprotocol/sdk@1.32.1 and @modelcontextprotocol/server@2.3.1, or builds fail with unresolved imports.
  • Persistent browserTool: Adds Chrome DevTools Protocol (CDP) browser automation via Browser Run that preserves tabs, cookies, and login sessions across agent turns.

Confidence Assessment: High for GitHub repository metrics (6.2K stars, 885 forks, MIT license, Node 24+ dev requirement), Cloudflare Agents changelog entries, and exact MCP peer dependency pins. Medium for exact trailing 30-day npm download counts for agents, as npm's public snippet omits the raw monthly figure.


Adoption Telemetry & Version Changelog

npm & GitHub Telemetry (Verified December 3, 2026)

Metric Verified Value Source & Verification Date
Package & Ecosystem agents (plus hono-agents, 633 versions) on npm npm agents / npm hono-agents
GitHub Repository 6.2K stars · 885 forks · cloudflare/agents GitHub (Dec 3, 2026)
License & Runtime MIT (agents), ISC (hono-agents); Node 24+ (repo dev); Workers nodejs_compat GitHub / Cloudflare Docs
Pinned MCP Dependencies @modelcontextprotocol/sdk@1.32.1 · @modelcontextprotocol/server@2.3.1 GitHub Releases
Recent Changelog Window Nov 21 – Nov 25, 2026 (browserTool, Pi 1.6, claude-sonnet-5-5) Cloudflare Agents Changelog

Key Architecture & Ecosystem Milestones

Unlike stateless serverless functions that lose memory between HTTP requests, Cloudflare's agents SDK binds each agent instance to a Durable Object backed by SQLite storage:

  1. Hibernation-First Billing: Agents sleep between incoming WebSocket or HTTP requests so idle sessions incur no compute charge while retaining conversation history, scheduled tasks (this.schedule(...)), and human-in-the-loop workflow state (waitForApproval()).
  2. Modular Entry Points: Separate entry points (agents/voice, agents/experimental/channels, agents/mcp, agents/mcp/server) ensure bundlers tree-shake unused integrations out of the Worker bundle.
  3. Hono Integration (hono-agents): The companion hono-agents package (633 published versions, ISC license) mounts agentsMiddleware onto Hono routers to handle WebSocket upgrades and HTTP routing, with explicit path-prefix scoping recommended so agent rejections do not short-circuit sibling WebSocket routes.

Security Patches, Breaking Changes & Internals

Breaking Changes & Irreversible State Transitions

Upgrading agents in late 2026 requires careful staging because three changes alter either persisted Durable Object state or TypeScript compilation:

  1. One-Way Pi 1.6 Upgrade (No Rollback to Pi 1.5): According to the Cloudflare Agents Changelog (November 25, 2026), once a conversation executes on Pi 1.6, Pi 1.5 cannot run its tool calls or model requests. In addition, signal delivery changed from (await harness.pi()).signal() to harness.signal(). If a deployment hits an issue after upgrading, teams must roll forward with a patch rather than reverting the Worker version to Pi 1.5.
  2. Mandatory MCP SDK Peer Bumps: Per GitHub Releases, builds fail with unresolved import errors unless you pin the exact MCP packages expected by each subpath:
    • agents/mcp (McpAgent, WorkerTransport, createLegacyMcpHandler) and agents/x402: @modelcontextprotocol/sdk@1.32.1 and @modelcontextprotocol/server@2.3.1.
    • agents/mcp/server (createMcpHandler): @modelcontextprotocol/server@2.3.1.
    • agents/experimental/webmcp: @modelcontextprotocol/sdk@1.32.1.
  3. TypeScript exactOptionalPropertyTypes Rename: Applications compiling with exactOptionalPropertyTypes must update DurableObjectOAuthClientProvider to OAuthClientProvider, and Browser to BrowserSource, alongside newly exported normalizeCdpSpec.
  4. Model Deprecation Cutoff (Nov 20 & Nov 30, 2026): claudeCode() now defaults to claude-sonnet-5-5 because claude-sonnet-4-5 retired on November 30, 2026 (PR #2895), and example templates dropped Workers AI models retired on November 20, 2026.

Persistent browserTool & CDP Security Boundaries

The new browserTool gives agents a persistent Browser Run session driven over the Chrome DevTools Protocol (CDP). Because the browser keeps tabs, cookies, and authenticated login sessions alive across turns—returning screenshots for multimodal models to inspect—engineering teams should isolate untrusted browsing tasks into dedicated per-user Durable Objects (ClaudeCodeAgent + ContainerEgress patterns documented in Cloudflare's Claude Code harness docs) and avoid sharing browser sessions across tenants.

Dual-Era MCP Support: Why Both 1.32.1 and 2.3.1 Are Pinned

Developers inspecting cloudflare/agents are often surprised to see both @modelcontextprotocol/sdk@1.32.1 and @modelcontextprotocol/server@2.3.1 required simultaneously. As documented in the MCP TypeScript SDK migration guide, the TypeScript MCP ecosystem split into two distinct lines:

  • Legacy v1.x (@modelcontextprotocol/sdk@1.32.1): Implements the initialize-handshake era through protocol revision 2025-11-25, which agents/mcp (createLegacyMcpHandler, WorkerTransport), agents/x402, and agents/experimental/webmcp still rely on.
  • Modern v2.x (@modelcontextprotocol/server@2.3.1): Implements the stateless 2026-07-28 MCP specification (server/discover, requestState round-tripping without Mcp-Session-Id), powering createMcpHandler inside agents/mcp/server. Pinning both packages prevents TypeScript type collisions and unresolved-import build failures during Workers bundling.

Durable Workflows & hono-agents Routing Gotchas

For teams combining agents with Cloudflare Workflows or Hono, two architectural details from the npm documentation and hono-agents matter in production:

  • Human-in-the-Loop & Long-Running Steps: Workflows inside agents support automatic step retries across failures, waitForApproval() pauses for human sign-off, and multi-day or multi-week execution alongside resumable AI chat streaming.
  • Prefix Isolation in hono-agents: Once agentsMiddleware() matches an incoming request, its response—including an HTTP rejection—is returned immediately without invoking downstream Hono handlers. Always mount agentsMiddleware on a dedicated prefix (such as /agents) rather than "*" if your Worker serves unrelated WebSocket endpoints.

Updated TypeScript Usage (createMcpHandler + claudeCode)

import { Agent, callable } from "agents";
import { createMcpHandler } from "agents/mcp/server";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

// Requires @modelcontextprotocol/server@2.3.1 for agents/mcp/server
type State = { tasksCompleted: number };

export class OpsAgent extends Agent<Env, State> {
  initialState: State = { tasksCompleted: 0 };

  @callable()
  async recordTask(): Promise<State> {
    const next = { tasksCompleted: this.state.tasksCompleted + 1 };
    this.setState(next);
    return next;
  }
}

export function buildMcpWorker(server: McpServer) {
  return createMcpHandler(server);
}

Note that Vite-based projects must extend agents/tsconfig and register the agents/vite plugin, while other bundlers must enable TC39 decorators (2023-11) so @callable() compiles cleanly.


Ecosystem Comparison & Upgrade Checklist

TypeScript / Edge Agent SDK Comparison (Verified December 2026)

SDK / Package Primary Runtime MCP Support Key State & Hosting Trade-Offs
Cloudflare agents (6.2K stars, MIT) Cloudflare Workers + Durable Objects (SQLite) @modelcontextprotocol/sdk@1.32.1 + @modelcontextprotocol/server@2.3.1 Built-in hibernation, cron, WebSockets, and browserTool; tied to Cloudflare Workers runtime
@modelcontextprotocol/server (2.3.1) Node.js 20+, Bun, Deno, Workers Native 2026-07-28 MCP spec (createMcpHandler) Pure protocol server without built-in agent memory, scheduling, or Durable Object persistence
hono-agents (633 versions, ISC) Hono + Cloudflare Workers Inherits agents MCP & WebSocket routing Thin Hono middleware (agentsMiddleware); requires explicit route prefixing for multi-WS apps

Monorepo Footprint & Deprecated Sub-Packages

Teams auditing cloudflare/agents from source or tracking upstream breaking changes should note several structural details from the GitHub monorepo:

  • Deprecated Packages: The legacy shell/ sandboxed execution filesystem and packages/voice/ compatibility wrapper are marked deprecated in favor of dedicated harness entry points (agents/voice with withVoice / VoiceClient / useVoiceAgent) and container-backed ClaudeCodeAgent bindings (nodejs_compat compatibility flag).
  • Runtime Workers Bundler: The monorepo includes packages/worker-bundler/ alongside packages/hono-agents/ and openai-sdk/ integration examples, managed via pnpm workspaces and Nx (requiring Node 24+ for contributors building from source).
  • External Contribution Policy: Cloudflare notes that external pull requests are currently closed while the SDK's surface area evolves rapidly; teams needing custom extensions should wrap Agent or createMcpHandler in application code rather than maintaining private forks.

Safe Upgrade & Pinning Checklist

  1. Bump MCP Dependencies Together: Update package.json before running pnpm install or npm install so agents/mcp and agents/mcp/server resolve cleanly:
    npm install agents @modelcontextprotocol/sdk@1.32.1 @modelcontextprotocol/server@2.3.1
    
  2. Stage Pi 1.6 Migration Carefully: Because conversations touched by Pi 1.6 cannot revert to Pi 1.5, test harness.signal() and tool calls in a staging Worker environment before promoting to production.
  3. Audit claude-sonnet-4-5 Overrides: Search your codebase for hardcoded "claude-sonnet-4-5" strings or Workers AI models retired in November 2026; let claudeCode() use its new claude-sonnet-5-5 default or call session.setModel() explicitly. 3b. Verify Bundler & wrangler Compatibility Flags: For Vite apps, confirm tsconfig.json extends agents/tsconfig and loads the agents/vite plugin; in wrangler config, ensure nodejs_compat is enabled (Cloudflare's ClaudeCodeAgent docs reference compatibility date 2026-11-06 with SQLite-backed Durable Objects).
  4. Update TypeScript Interfaces: Replace DurableObjectOAuthClientProvider with OAuthClientProvider and Browser with BrowserSource if exactOptionalPropertyTypes is enabled in tsconfig.json.

Frequently Asked Questions

1. Can I roll back to Pi 1.5 if something breaks after upgrading Cloudflare Agents to Pi 1.6?

No. Cloudflare's official changelog warns that once a conversation runs on Pi 1.6, Pi 1.5 cannot execute its tool calls or model requests. You must roll forward with fixes rather than rolling back.

2. Why does my Cloudflare Agents build fail with unresolved MCP imports?

The agents SDK requires exact MCP package versions: @modelcontextprotocol/sdk@1.32.1 and @modelcontextprotocol/server@2.3.1 for agents/mcp and agents/x402, and @modelcontextprotocol/server@2.3.1 for agents/mcp/server. Pinning both resolves the build error.

3. Which Claude model does claudeCode() use by default now?

Following the November 30, 2026 retirement of claude-sonnet-4-5, claudeCode() now defaults to claude-sonnet-5-5 (which can still be overridden per session via session.setModel()).

4. What does browserTool add to Cloudflare Agents?

browserTool connects your agent to a persistent Browser Run instance controlled by model-generated code over the Chrome DevTools Protocol (CDP), preserving tabs, cookies, and authenticated login sessions across turns and returning screenshots for image-capable models.

5. Do idle Cloudflare Agents consume compute billing?

No. Built on Cloudflare Durable Objects, agents automatically hibernate between WebSocket or HTTP requests so idle instances incur zero compute cost while keeping SQLite state, conversation history, and this.schedule(...) cron tasks intact across restarts.


Sources

  1. Cloudflare Developers Changelog — Agents Changelog (browserTool, Pi 1.6, claude-sonnet-5-5) (https://developers.cloudflare.com/changelog/product/agents/) — Published Nov 25, 2026.
  2. GitHub (cloudflare/agents) — Releases & Repository (MIT, 6.2K stars, MCP pins) (https://github.com/cloudflare/agents and https://github.com/cloudflare/agents/releases) — Accessed Dec 3, 2026.
  3. Cloudflare Developers Docs — Claude Code Harness (nodejs_compat, claude-sonnet-5-5) (https://developers.cloudflare.com/agents/harnesses/claude-code/) — Published Nov 21, 2026.
  4. npm (agents & hono-agents) — Cloudflare Agents SDK Package Documentation (https://www.npmjs.com/package/agents and https://www.npmjs.com/package/hono-agents) — Accessed Dec 3, 2026.
  5. Model Context Protocol TypeScript SDK — Supporting protocol revision 2026-07-28 (https://github.com/modelcontextprotocol/typescript-sdk/blob/main/docs/migration/support-2026-07-28.md) — Accessed Dec 3, 2026.

More on Packages

Tell us what is not working

A thirty-minute call, no deck and no obligation. You will leave with a straight answer about whether this is worth building - including if that answer is no.

Start a project

Direct line

hello@codebumble.net
Dhaka, Bangladesh  :   local timeCalls in English or Bangla