← Back
Cloudflare
Cloudflare Agents SDK v0.5.0 adds retry utilities, protocol message control, and data parts

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 deletion
  • body option on useAgentChat — Send custom data with every request (static or dynamic)
  • autoContinueAfterToolResult defaults to true — Client-side tool results and approvals now automatically trigger server continuation

Additional Improvements

  • Synchronous queue/schedule getters — Methods like getQueue(), getSchedule(), and dequeue() are now synchronous and return values directly instead of Promises. Existing code using await remains compatible.
  • TypeScript depth fix — A depth counter on CanSerialize types prevents "excessively deep" instantiation errors with nested structures like CoreMessage[]
  • POST SSE keepalive — The POST SSE handler now sends event: ping every 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-chat and @cloudflare/codemode marked 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.