Retry Utilities
A new this.retry() method allows you to retry any async operation with exponential backoff and jitter. You can optionally pass a shouldRetry predicate to bail early on non-retryable errors. Retry options are also available per-task on queue(), schedule(), scheduleEvery(), and addMcpServer(), with configurations persisted in SQLite alongside tasks. Class-level retry defaults can be set via static options, and all options are validated eagerly at enqueue/schedule time. Internal retries have been added for workflow operations with Durable Object-aware error detection.
Per-Connection Protocol Message Control
Agents automatically send JSON text frames to every WebSocket connection. You can now suppress these protocol messages per-connection via the shouldSendProtocolMessages() hook—useful for binary-only devices, MQTT clients, or lightweight embedded systems. Connections with protocol messages disabled still fully participate in RPC and regular messaging, and you can check a connection's status using isConnectionProtocolEnabled(). The flag persists across Durable Object hibernation.
@cloudflare/ai-chat v0.1.0
The first stable release of @cloudflare/ai-chat includes a major internal refactor with zero breaking changes. Existing code using AIChatAgent and useAgentChat works without modification.
New capabilities:
- Data parts — Attach typed JSON blobs (
data-*) to messages alongside text, with support for reconciliation, append, and transient parts - Tool approval persistence — The approval UI now survives page refresh and Durable Object hibernation by persisting messages to SQLite
maxPersistedMessages— Cap SQLite storage with automatic oldest-message deletionbodyoption onuseAgentChat— Send custom data with every request (static or dynamic)autoContinueAfterToolResultdefaults totrue— Client-side tool results and approvals now automatically trigger server continuation
Additional Improvements
- Synchronous queue/schedule getters — Methods like
getQueue(),getSchedule(), anddequeue()are now synchronous and return values directly instead of Promises. Existing code usingawaitremains compatible. - TypeScript depth fix — A depth counter on
CanSerializetypes prevents "excessively deep" instantiation errors with nested structures likeCoreMessage[] - POST SSE keepalive — The POST SSE handler now sends
event: pingevery 30 seconds to prevent connection drops during long-running tool calls - Widened peer dependencies — Peer dependency ranges have been expanded to prevent cascading major bumps, with
@cloudflare/ai-chatand@cloudflare/codemodemarked as optional
Notable bug fixes address stream resumption race conditions, setMessages functional updater issues, client tool schema loss after hibernation, and message metadata propagation on broadcast/resume paths.