Skip to content

fix(chat): make durable recovery unconditional - #2071

Open
ben-reitz wants to merge 4 commits into
mainfrom
fix/unconditional-chat-recovery
Open

fix(chat): make durable recovery unconditional#2071
ben-reitz wants to merge 4 commits into
mainfrom
fix/unconditional-chat-recovery

Conversation

@ben-reitz

@ben-reitz ben-reitz commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #2044.

Remove chatRecovery = false

This removes the option to disable durable chat recovery in AIChatAgent and Think. Every chat turn now runs in a recovery fiber. chatRecovery remains available for tuning recovery budgets and terminal behavior.

Previously compiled JavaScript that still supplies false receives 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 false users

Remove the assignment. If recovery must not issue another model call, return { continue: false } from onChatRecovery() 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 false value, 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.


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cecfb37

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
agents Minor
@cloudflare/ai-chat Minor
@cloudflare/think Minor
@cloudflare/agent-think Patch

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

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

Comment thread docs/think/sub-agents.md Outdated
@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

agents

npm i https://pkg.pr.new/agents@2071

@cloudflare/ai-chat

npm i https://pkg.pr.new/@cloudflare/ai-chat@2071

@cloudflare/codemode

npm i https://pkg.pr.new/@cloudflare/codemode@2071

create-think

npm i https://pkg.pr.new/create-think@2071

hono-agents

npm i https://pkg.pr.new/hono-agents@2071

@cloudflare/shell

npm i https://pkg.pr.new/@cloudflare/shell@2071

@cloudflare/think

npm i https://pkg.pr.new/@cloudflare/think@2071

@cloudflare/voice

npm i https://pkg.pr.new/@cloudflare/voice@2071

@cloudflare/worker-bundler

npm i https://pkg.pr.new/@cloudflare/worker-bundler@2071

commit: cecfb37

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Think: inspectAgentToolRun throws when chatRecovery = false agent-tool child

1 participant