Repository navigation
fix(ai-chat): route platform-transient reader errors into bounded recovery - #2360
Conversation
…overy (#1964) Co-authored-by: Cursor <cursoragent@cursor.com>
🦋 Changeset detectedLatest commit: 88f146b The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
⚪ agents import sizesMeasured 344 runtime imports as minified bundles. The primary size is gzip; raw minified size is included for diagnosis. An existing import growing by more than 10% is marked red. This report is informational.
Compared No import sizes changed. All 344 current runtime imports
Reported by agent-think[bot]. |
agents
@cloudflare/ai-chat
@cloudflare/codemode
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
…ntinuing Co-authored-by: Cursor <cursoragent@cursor.com>
|
|
||
| If the agent is evicted mid-stream, the fiber row survives in SQLite. On the next activation, the framework detects the interrupted fiber, reconstructs the partial response from buffered stream chunks, and calls `onChatRecovery`. | ||
|
|
||
| The same bounded recovery handles an `AIChatAgent` stream that fails while the agent stays up. If the response reader throws a platform transient error, such as `Network connection lost.`, the agent keeps the partial response and schedules a continuation instead of ending the turn with an error. Other reader errors still end the turn. |
There was a problem hiding this comment.
The docs here are ported to cloudflare-docs by hand (there is no sync workflow). I will open the matching cloudflare-docs change once this lands; leaving this thread open until then.
…errors Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ry for transient reader errors Ports upstream cloudflare#2194, cloudflare#2190, cloudflare#2223, cloudflare#2360, cloudflare#2385 and cloudflare#2393 to AGUIChatAgent. - Recovery attempts are __cf_internal_chat_recovery Task runs dispatched to the model handoff; a root agent's chat turn is a Task run (facets stay on fibers). The origin-ids scope moves into the dispatch wrapper. - The progress marker is derived from the stream log; a settled TOOL_CALL_RESULT is flushed as it lands. - A platform-transient reader error routes into bounded recovery like a stall: onChatRecovery is consulted with the live turn's stash data, persist:false drops the partial, a blank new turn is retried, and a running attempt that reschedules leaves the incident to its successor. - A cancel during backoff cancels the queued recovery. - An auto-continuation that fails before streaming sends an error frame and reaches onChatResponse. The agui test worker follows the Tasks transport and the derived marker.
Fixes #1964.
Summary
AIChatAgentended the turn with an error when the model response reader failed with a platform-transient error such asNetwork connection lost.. Those errors now go through bounded chat recovery, the same way a stream stall does: the partial response is kept and a continuation is scheduled. Deploy and storage resets are excluded, because the restart's own recovery handles them. Other reader errors still end the turn as before.Tests
durable-chat-recovery.test.ts, "platform-transient reader errors (AIChatAgent terminalizes platform-transient response reader errors instead of routing them through chatRecovery #1964)":