fix(chat): make durable recovery unconditional - #2071
Open
ben-reitz wants to merge 4 commits into
Open
Conversation
🦋 Changeset detectedLatest commit: cecfb37 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 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
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2044.
Remove
chatRecovery = falseThis removes the option to disable durable chat recovery in
AIChatAgentand Think. Every chat turn now runs in a recovery fiber.chatRecoveryremains available for tuning recovery budgets and terminal behavior.Previously compiled JavaScript that still supplies
falsereceives the default recovery configuration.Why the opt-out is unnecessary
The opt-out tied two separate concerns together: durable bookkeeping and automatic continuation. Users may need to prevent another model call, but the SDK still needs a durable record of the running turn.
Issue #2044 exposed one consequence of skipping that record. An agent-tool inspection handled by a fresh JavaScript instance could not see another instance's in-memory stream state. It could throw during inspection or mark a child as failed while that child was still running successfully.
Keeping the durable record for every turn removes that unsafe branch. Applications can still decline automatic continuation without giving up durable bookkeeping.
For existing
falseusersRemove the assignment. If recovery must not issue another model call, return
{ continue: false }fromonChatRecovery()instead. Cancellation intent, side-effect completion, or spend limits should be stored durably and consulted by that hook; recovery budgets remain available as an additional bound.Tests
A regression test runs an agent-tool child with the legacy
falsevalue, kills it during streaming, and verifies that recovery completes and the parent receives the real terminal result.Suites: agents chat 514 · AI Chat workers 655 · Think workers 919 · agent-tool recovery E2E ·
pnpm run check.