Agents SDK v0.12.4 — chat recovery, routing retries, durable Think, and Voice connection control
Key Points
- Chat recovery keeps server turns running
- Durable Think.submitMessages with idempotent retries
- useVoiceAgent now supports delayed connection
Summary
Agents SDK v0.12.4 improves reliability around long-running chat turns, reconnects, Durable Object routing, and Think submissions. It introduces durable programmatic submissions for @cloudflare/think, exposes routing retry configuration for transient DO routing failures, and gives Voice agents a connection control flag to delay client creation until prerequisites are ready. Several bug fixes improve agent state synchronization and stream resume behavior.
Key Points
- Chat recovery: @cloudflare/ai-chat now keeps server-side turns running when a browser/client stream aborts; caller can set
cancelOnClientAbort: trueto cancel on client aborts. Resume/no-race bugs and streaming-state resets fixed. - Routing retries:
getAgentByName(..., { routingRetry: { maxAttempts } })supports configurable transient Durable Object routing retries to reduce lookup failures. - Durable Think submissions:
@cloudflare/thinkaddssubmitMessages()for durable acceptance (idempotent retries, status inspection, cancellation, cleanup).Think.chat()turns persist stream chunks and recover partial sub-agent output. - Pruning change:
pruneMessages({ toolCalls: "before-last-2-messages" })is no longer applied by default;truncateOlderMessagesstill bounds context cost. Subclasses can opt back in viabeforeTurn. - Voice connection control:
useVoiceAgent({ enabled })lets apps delay creating/connecting a VoiceClient until tokens/prereqs are ready. - Agent state fixes: prevents duplicate initial state frames on WebSocket setup, defers user finish hooks until after agent startup, and isolates hook failures to avoid blocking other recoveries.
- Misc: streamable HTTP routing, preserved structured tool output during truncation, non-chat Think tool steps support structured outputs, stale sub-agent schedule pruning, and @cloudflare/codemode browser-safe sandbox export.
Migration / Upgrade Notes
ChatOptions.toolsremoved from TS API; define durable tools on child agents or use agent-level tools. Legacy runtimeoptions.toolsare ignored with a warning.- Upgrade via npm:
npm i agents@latest @cloudflare/ai-chat@latest @cloudflare/think@latest @cloudflare/voice@latest.
Key Files / APIs to review
- useAgentChat (cancelOnClientAbort)
- getAgentByName (routingRetry)
- @cloudflare/think: submitMessages, Think.chat()
- useVoiceAgent (enabled)
When to act
- Adopt
routingRetryfor transient DO routing issues, migrate any logic depending on old aggressive pruning, and switch tool definitions if you usedChatOptions.tools.