fix(chat): make durable recovery unconditional - #2071
Conversation
🦋 Changeset detectedLatest commit: 8b0cc15 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 |
| Instead of `chatRecovery = true`, assign an object to tune how long recovery is allowed to run and when it is given up on. A turn that keeps making forward progress survives unbounded interruption — duration is not a bound — as long as it stays under the `maxRecoveryWork` backstop. Recovery is only sealed by one of the limits below. | ||
| Assign a `chatRecovery` object to tune how long recovery is allowed to run and when it is given up on. A turn that keeps making forward progress survives unbounded interruption — duration is not a bound — as long as it stays under the `maxRecoveryWork` backstop. Recovery is only sealed by one of the limits below. | ||
|
|
||
| `chatRecovery = false` is no longer supported. If automatic continuation is unsafe, return `{ continue: false }` from `onChatRecovery()`. For cancellation that must survive hibernation, store cancellation intent durably and check it in that hook. See [Migrating from `chatRecovery = false`](../agents/chat-agents.md#migrating-from-chatrecovery--false) for side-effect and cost guidance. |
There was a problem hiding this comment.
🟡 Recovery migration link in the Think sub-agent docs points to a section that does not exist
A new sentence in the Think sub-agents page links readers to a "Migrating from chatRecovery = false" section (../agents/chat-agents.md#migrating-from-chatrecovery--false at docs/think/sub-agents.md:440) that was never added, and it uses a relative path across package documentation directories instead of the absolute repository URL the docs conventions require.
Impact: Readers following the migration pointer land on the wrong place in the page, and the link style is inconsistent with the rest of the cross-package links.
Missing anchor and cross-directory link convention
The PR added the "Controlling automatic continuation" section to docs/agents/chat-agents.md:654, not a "Migrating from chatRecovery = false" heading, so the anchor #migrating-from-chatrecovery--false resolves to nothing.
docs/AGENTS.md states: "Link within a package directory using relative paths (./state.md); Link across package directories with an absolute repository URL." Other cross-package links in the same file follow that rule (e.g. docs/think/sub-agents.md:475 uses https://github.com/cloudflare/agents/blob/main/docs/agents/chat-agents.md#stream-recovery).
| `chatRecovery = false` is no longer supported. If automatic continuation is unsafe, return `{ continue: false }` from `onChatRecovery()`. For cancellation that must survive hibernation, store cancellation intent durably and check it in that hook. See [Migrating from `chatRecovery = false`](../agents/chat-agents.md#migrating-from-chatrecovery--false) for side-effect and cost guidance. | |
| `chatRecovery = false` is no longer supported. If automatic continuation is unsafe, return `{ continue: false }` from `onChatRecovery()`. For cancellation that must survive hibernation, store cancellation intent durably and check it in that hook. See [Controlling automatic continuation](https://github.com/cloudflare/agents/blob/main/docs/agents/chat-agents.md#controlling-automatic-continuation) for side-effect and cost guidance. |
Was this helpful? React with 👍 or 👎 to provide feedback.
agents
@cloudflare/ai-chat
@cloudflare/codemode
create-think
hono-agents
@cloudflare/shell
@cloudflare/think
@cloudflare/voice
@cloudflare/worker-bundler
commit: |
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.