Feature
Agents SDK v0.12.4: chat recovery, routing retries, durable Think submissions, and Voice connection control
The latest release of the Agents SDK brings more reliable chat recovery, fixes Agent state synchronization during reconnects, adds durable submissions for Think, exposes routing retry configuration, and adds connection control for Voice agents.
Chat recovery improvements
@cloudflare/ai-chat now keeps server turns running when a browser or client stream is interrupted. This is useful for long-running AI responses where users refresh the page, close a tab, or temporarily lose connection. Calling stop() still cancels the server turn.
Set cancelOnClientAbort: true if browser or client aborts should also cancel the server turn:
const chat = useAgentChat({ agent: "assistant", name: "user-123", cancelOnClientAbort: true, });
const chat = useAgentChat({ agent: "assistant", name: "user-123", cancelOnClientAbort: true, });
Notable bug fixes:
- Chat stream resume negotiation no longer throws when replay races with a closed WebSocket connection.
- Recovered chat continuations no longer leave useAgentChat stuck in a streaming state when the original socket disconnects before a terminal response.
- Approval auto-continuation preserves reasoning parts and persists continuation reasoning in the final message.
- isServerStreaming now resets correctly when a resumed stream moves from the fallback observer path to a transport-owned stream.
Agent state and routing fixes
agents@0.12.4 prevents duplicate initial state frames during WebSocket connection setup. This avoids stale initial state messages overwriting state updates already sent by the client.
Agent recovery is also more reliable when tool calls span a Durable Object restart. Recovery now defers user finish hooks until after agent startup and isolates hook failures, so one failed hook does not block other recovered runs from finalizing.
getAgentByName() now supports routingRetry for transient Durable Object routing failures:
import { getAgentByName } from "agents"; const agent = await getAgentByName(env.AssistantAgent, "user-123", { routingRetry: { maxAttempts: 3, }, });
import { getAgentByName } from "agents"; const agent = await getAgentByName(env.AssistantAgent, "user-123", { routingRetry: { maxAttempts: 3, }, });
Durable Think submissions
Read the original announcement