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.
8 min read
Cloudflare Agents SDK (agents): Pi 1.6 Harness, BrowserTool CDP, and MCP 2.3.1 Upgrade Guide
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.6State Migration: Once a conversation runs on Pi1.6, Pi1.5can no longer execute its tool calls or model requests—teams must roll forward rather than rolling back. - Model Retirement & Default Swap:
claudeCode()now defaults toclaude-sonnet-5-5following the November 30, 2026 retirement ofclaude-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, andagents/experimental/webmcprequire explicit bumps to@modelcontextprotocol/sdk@1.32.1and@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:
- 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()). - 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. - Hono Integration (
hono-agents): The companionhono-agentspackage (633published versions,ISClicense) mountsagentsMiddlewareonto 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:
- One-Way Pi
1.6Upgrade (No Rollback to Pi 1.5): According to the Cloudflare Agents Changelog (November 25, 2026), once a conversation executes on Pi1.6, Pi1.5cannot run its tool calls or model requests. In addition, signal delivery changed from(await harness.pi()).signal()toharness.signal(). If a deployment hits an issue after upgrading, teams must roll forward with a patch rather than reverting the Worker version toPi 1.5. - 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) andagents/x402:@modelcontextprotocol/sdk@1.32.1and@modelcontextprotocol/server@2.3.1.agents/mcp/server(createMcpHandler):@modelcontextprotocol/server@2.3.1.agents/experimental/webmcp:@modelcontextprotocol/sdk@1.32.1.
- TypeScript
exactOptionalPropertyTypesRename: Applications compiling withexactOptionalPropertyTypesmust updateDurableObjectOAuthClientProvidertoOAuthClientProvider, andBrowsertoBrowserSource, alongside newly exportednormalizeCdpSpec. - Model Deprecation Cutoff (
Nov 20 & Nov 30, 2026):claudeCode()now defaults toclaude-sonnet-5-5becauseclaude-sonnet-4-5retired 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 theinitialize-handshake era through protocol revision2025-11-25, whichagents/mcp(createLegacyMcpHandler,WorkerTransport),agents/x402, andagents/experimental/webmcpstill rely on. - Modern
v2.x(@modelcontextprotocol/server@2.3.1): Implements the stateless2026-07-28MCP specification (server/discover,requestStateround-tripping withoutMcp-Session-Id), poweringcreateMcpHandlerinsideagents/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
agentssupport 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: OnceagentsMiddleware()matches an incoming request, its response—including an HTTP rejection—is returned immediately without invoking downstream Hono handlers. Always mountagentsMiddlewareon 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 andpackages/voice/compatibility wrapper are marked deprecated in favor of dedicated harness entry points (agents/voicewithwithVoice/VoiceClient/useVoiceAgent) and container-backedClaudeCodeAgentbindings (nodejs_compatcompatibility flag). - Runtime Workers Bundler: The monorepo includes
packages/worker-bundler/alongsidepackages/hono-agents/andopenai-sdk/integration examples, managed viapnpmworkspaces andNx(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
AgentorcreateMcpHandlerin application code rather than maintaining private forks.
Safe Upgrade & Pinning Checklist
- Bump MCP Dependencies Together: Update
package.jsonbefore runningpnpm installornpm installsoagents/mcpandagents/mcp/serverresolve cleanly:npm install agents @modelcontextprotocol/sdk@1.32.1 @modelcontextprotocol/server@2.3.1 - Stage Pi
1.6Migration Carefully: Because conversations touched by Pi1.6cannot revert to Pi1.5, testharness.signal()and tool calls in a staging Worker environment before promoting to production. - Audit
claude-sonnet-4-5Overrides: Search your codebase for hardcoded"claude-sonnet-4-5"strings or Workers AI models retired in November 2026; letclaudeCode()use its newclaude-sonnet-5-5default or callsession.setModel()explicitly. 3b. Verify Bundler &wranglerCompatibility Flags: For Vite apps, confirmtsconfig.jsonextendsagents/tsconfigand loads theagents/viteplugin; inwranglerconfig, ensurenodejs_compatis enabled (Cloudflare'sClaudeCodeAgentdocs reference compatibility date2026-11-06with SQLite-backed Durable Objects). - Update TypeScript Interfaces: Replace
DurableObjectOAuthClientProviderwithOAuthClientProviderandBrowserwithBrowserSourceifexactOptionalPropertyTypesis enabled intsconfig.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
- Cloudflare Developers Changelog — Agents Changelog (
browserTool,Pi 1.6,claude-sonnet-5-5) (https://developers.cloudflare.com/changelog/product/agents/) — Published Nov 25, 2026. - GitHub (
cloudflare/agents) — Releases & Repository (MIT,6.2Kstars, MCP pins) (https://github.com/cloudflare/agentsandhttps://github.com/cloudflare/agents/releases) — Accessed Dec 3, 2026. - Cloudflare Developers Docs — Claude Code Harness (
nodejs_compat,claude-sonnet-5-5) (https://developers.cloudflare.com/agents/harnesses/claude-code/) — Published Nov 21, 2026. - npm (
agents&hono-agents) — Cloudflare Agents SDK Package Documentation (https://www.npmjs.com/package/agentsandhttps://www.npmjs.com/package/hono-agents) — Accessed Dec 3, 2026. - 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.