Skip to content

test(think): group A chat-recovery successors through public behaviour (resets, budgets, regeneration, platform cuts) - #3455

Merged
mattzcarey merged 13 commits into
mainfrom
slim/harness-A-successors-8
Nov 27, 2026
Merged

mattzcarey merged 13 commits into
mainfrom
slim/harness-A-successors-8

Conversation

@mattzcarey

@mattzcarey mattzcarey commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Group A's chat-recovery successors after batch 2 (#3437), folded into one PR as Matt asked: one commit per change, each green alone. Stacked on #3437. Tests only, no changeset. The descriptions of the PRs folded in (#3443, #3445, #3449, #3452, #3454 and this one) follow, one section each.

On the harness config, each says which shell step makes it pass: most need A-4 (the turn definition's recovery budget), persist: false needs A-5, and the rest pass now.

test(think): public successors for onChatRecovery's continue/persist false after a reset (group A)

Group A's next batch of successors: what a turn a reset interrupted leaves behind when onChatRecovery declines, through public behaviour on both configs. Theme (b) in harness's order. Stacked on #3437. Tests only, no changeset.

Each test resets the isolate mid-reply with ctx.abort, as an eviction does, using resetDuringTurn, which now lives at file scope. The next start recovers the turn and asks onChatRecovery. The answer was stored with a new fixture, answerRecoveryForTest, in the agent's storage, so the isolate after the reset gives it. The test then waits until the agent is stable and reads the transcript.

Successor Class Harness-backed
"keeps the partial but runs no continuation when onChatRecovery says continue: false" passes passes
"keeps nothing and runs nothing when onChatRecovery says persist: false, continue: false" passes fails (persist: false is A-5)

Class-only row (1): onChatRecovery › "{ continue: false } persists but does not schedule continuation". It builds its interrupted turn from seeded private stream rows and recovers it by hand. Its successor is the reset test above, which passes on both configs. "{ persist: false, continue: false } skips both" gets its row when its successor passes on the shell.

Batch 3 (progress resetting the budget) is held. On Think, what an app sees contradicts the promise: the attempt number resets on progress, but the give-up counts every interruption. The finding is with the deputy.

On the harness config: "continue: false" passes now; "persist: false, continue: false" passes with A-5.

On the harness config: "continue: false" passes now; "persist: false, continue: false" passes with A-5.


test(think): public successors for a stall's attempt count and give-up (group A)

Group A successors for "progress and the attempt budget", written to arch's ruling ("arch ruling (std A progress)"). Stacked on #3443. Tests only, no changeset.

Arch's ruling: one option drives two counts, on purpose.

  • A live interruption (a stall): each one is another scheduled retry. The turn gives up with max_attempts_exceeded at stall number maxAttempts + 1, whatever the progress.
  • onChatRecovery's attempt: the count that goes back to 1 when the last attempt made progress.

armLastingStallForTest gains a progressing option: each model call writes new text, 30 chunks, so some land in the stream log before the stall.

Successor Class Harness-backed
"tells onChatRecovery attempt 1 each time a stalled turn has made progress" passes fails until A-4
"gives a stalled turn up at stall maxAttempts + 1 even when every attempt makes progress" (two onChatRecovery calls, one max_attempts_exceeded) passes fails until A-4

Not written, and why:

  • "Without progress, 1 then 2": mechanics-only, the deputy's fallback. Recovery alarms within CHAT_RECOVERY_ALARM_DEBOUNCE_MS (30 s) collapse into one attempt, so two quick stalls without progress both report attempt 1 (measured on the class). Nothing in the test config moves the agent's clock, and a fixed 30 s wait isn't allowed. So that clause of 4634 gets no successor. Its row will say "needs interruptions more than CHAT_RECOVERY_ALARM_DEBOUNCE_MS apart; drives beginIncident", for rv-6 to confirm.
  • Resets with progress past maxAttempts up to maxInterruptedAttempts: this needs several real resets in one test. It's next. If the pool can't drive that many, the row is mechanics-only ("drives beginIncident"), per arch.
  • The work budget (4803): added. "seals a turn that keeps making progress once the work budget is spent" ends in work_budget_exceeded, with maxRecoveryWork: 2. It passes on the class.
  • Sub-agent forwarding (4671 and 4704), compaction (4734): next.

The class-only rows for 4634 and its siblings come when their successors pass on the shell.

On the harness config: all three (the attempt count with progress, the give-up at maxAttempts + 1, and the work budget) pass with A-4 (the turn definition's recovery budget).

On the harness config: all three (the attempt count with progress, the give-up at maxAttempts + 1, and the work budget) pass with A-4, the turn definition's recovery budget.


test(think): a public successor for the pre-stream retry after a real reset (group A)

Group A successors, theme (d), first part: a turn that a real reset cut off before its first chunk is answered again, with its user message once. Stacked on #3445. Tests only, no changeset.

The test resets the isolate while the model call is still waiting on the provider, before any stream (resetDuringTurn(…, 0), with hangModelAtConnectForTest). The next start recovers the turn and retries it, and the test waits until the agent is stable. The transcript then holds the user message once and a non-empty assistant answer. It passes on both configs.

Class-only row (1): onChatRecovery › "retries a pre-stream interrupted user turn by default without duplicating the user message". It builds the interrupted turn from a seeded private fiber and recovers it by hand. Its successor is the test above.

Still to do in (d): regeneration as a new branch (5443, 5499), which needs a socket regenerate before the reset, and the opened stream with no content (5632).

On the harness config: it passes now.

On the harness config: it passes now.


test(think): a public successor for the interrupted-attempts bound through real resets (group A)

A group A successor for the interrupted-attempts bound, through real resets, per arch's ruling ("arch ruling (std A progress)"). Stacked on #3449. Tests only, no changeset.

"recovers past maxAttempts across resets that each follow progress, until maxInterruptedAttempts": with chatRecovery set to { maxAttempts: 1, maxInterruptedAttempts: 3 }:

  1. A tab starts a slow reply. The test waits until the tab has new text (progress), then resets the isolate with ctx.abort.
  2. A new tab wakes the agent, and its start recovers the turn.
  3. This repeats. More than one reset is recovered, which is past maxAttempts, because each attempt made progress. Recovery then stops with chat:recovery:exhausted, reason interrupted_attempts_exceeded, a bound progress doesn't reset.

It passes on the class, 2/2. On the shell it fails until A-4.

Fixtures:

  • keepAcrossResetsForTest keeps a slow model and chatRecovery in the agent's storage.
  • ThinkTestAgent's chatRecovery field reads that storage when the agent is built, so recovery on the next start uses it.
  • lastAssistantTextForTest.

The pool can drive these resets, so this row needs no mechanics-only fallback. The class-only rows for 4634, 4765 and 4803 come once the shell passes their successors. The rows that name beginIncident's debounce stay mechanics-only, as #3445 says.

On the harness config: it passes with A-4 (the interrupted-attempts bound in the turn definition's budget).

On the harness config: with A-4 merged, it still fails on the shell: after the first reset, the recovered turn sends the new tab no text. Passed to harness.


test(think): a public successor for a regeneration a reset cut off (group A, #2028)

A group A successor for #2028, through a real reset: a regeneration that a reset cuts off is finished on its own new branch, and the earlier answer is kept. Theme (d). Stacked on #3452. Tests only, no changeset.

"finishes a regeneration a reset cut off on its new branch, keeping the earlier answer":

  1. A tab asks a question, and the turn completes.
  2. The tab sends a regenerate-message for the same user message, with a slow model. After two chunks, the isolate is reset with ctx.abort.
  3. A new tab wakes the agent, and its start recovers the regeneration.
  4. Once the agent is stable, the user message has two branches: the earlier answer, and the regenerated one, whose text starts with what the tab saw ("one …").

It passes on both configs.

Class-only row (1): onChatRecovery › "continues a regeneration interrupted after partial output on its new branch (#2028)". It builds the interrupted regeneration from seeded private stream rows and recovers it by hand. Its successor is the test above.

"retries a pre-stream interrupted regeneration as a new branch" (5443) needs the same reset, before the first chunk. It's next.

On the harness config: it passes now.

On the harness config: it passes now.


test(think): a public successor for a recovery the platform cut (group A)

A group A successor for "the recovery job was cut by the platform", as arch ruled ("arch ruling (std A platform error)"). Stacked on #3454. Tests only, no changeset.

"re-runs a recovery a reset cut while onChatRecovery ran, and sends no terminal":

  1. A turn is reset mid-reply (resetDuringTurn).
  2. The next start's recovery calls onChatRecovery, which the test holds on a gate (holdRecoveryOnceForTest; the agent's storage records that it's held and counts calls across resets).
  3. The test resets the isolate while the hook runs: the platform cuts the recovery attempt.
  4. A new tab wakes the agent. Its start runs the recovery again: a second onChatRecovery call. The agent goes stable with an answer, and there's no chat:recovery:exhausted and no error frame.

It passes on both configs.

Class-only rows (3), each injecting a platform reset into the class's private scheduled recovery callback, with this successor:

Probe-covered candidates (not marked here): "re-throws the SqlError shape (wrapped transient, retryable flag lost)" (#1730) and "re-throws a retryable-flagged platform error". Their fault is a platform error returned by a storage call, with no reset. They need verify's fault-suite scenario named per arch's third category, and the reviewer's confirmation. Verify is asked.

On the harness config: it passes now.

On the harness config: it passes now.


Included: #3437 test(think): public successors for the recovery budget's give-ups (group A, batch 2)

Group A's second batch of successors: when chat recovery gives up, and what onExhausted is told, through public behaviour on both configs. Theme (c), second in harness's order (A-4). Stacked on #3432. Tests only, no changeset.

A new fixture, armLastingStallForTest, stalls the next model streams and sets chatRecovery (maxAttempts, an onExhausted that records, and optionally shouldKeepRecovering) for as long as the agent lives. The test starts a turn and polls recoveryProgressForTest until recovery gives up. A's stallRecoveryForTest can't show a give-up: it returns after the first attempt, and it puts chatRecovery back before the attempts scheduled behind it run. Harness is told.

Successor Class Harness-backed
"gives up through onExhausted with max_attempts_exceeded once the attempts are spent" (reason, terminal message, root request id, no more than maxAttempts onChatRecovery calls) passes fails until A-4
"ends recovery with recovery_aborted when shouldKeepRecovering says no" passes fails until A-4

The rows for the old tests they succeed come once these pass on the shell: 7052's "routes a stall through the same exhaustion path…", 4359's "exhausts chat recovery after the configured max attempts", and 4849's "seals when the shouldKeepRecovering predicate returns false". #3387's check needs a successor that passes there. "Progress resets the budget" (4634 and its siblings) needs a model that writes new text on each attempt, so it's the next batch.

rv-3's FIX (last commit): (a) the regeneration test asserts the text finished after the reset (the fresh isolate's answer) and that the regenerated branch is the active one; (b) continue:false asserts no model call ran after the reset; (c) the interrupted-attempts test asserts exactly 3 resets (two recovered past maxAttempts 1, the third ends it); (d) the three platform-cut rows name the retries.test.ts classifier tests.

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5367af8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

agents

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

@cloudflare/ai-chat

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

@cloudflare/codemode

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

hono-agents

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

@cloudflare/shell

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

@cloudflare/think

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

@cloudflare/voice

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

@cloudflare/worker-bundler

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

commit: 5367af8

@agent-think

agent-think Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ agents import sizes: no significant changes (d5a44252 → 5367af8f, workflow run)

@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-7 branch from 005f4c7 to 7ca70c5 Compare November 27, 2026 10:34
@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-8 branch from ee59289 to 833448c Compare November 27, 2026 10:34
@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-7 branch from 7ca70c5 to fc5197d Compare November 27, 2026 10:44
@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-8 branch from 833448c to 96ed1af Compare November 27, 2026 10:44
@mattzcarey mattzcarey changed the title test(think): a public successor for a recovery the platform cut (group A) test(think): group A chat-recovery successors through public behaviour (resets, budgets, regeneration, platform cuts) Nov 27, 2026
@mattzcarey
mattzcarey changed the base branch from slim/harness-A-successors-7 to slim/harness-A-successors-2 November 27, 2026 10:52
@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-8 branch from 96ed1af to 7e9e48c Compare November 27, 2026 10:53
@mattzcarey
mattzcarey marked this pull request as ready for review November 27, 2026 11:01
devin-ai-integration[bot]

This comment was marked as resolved.

@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-2 branch from 30ad3ac to 3f218b2 Compare November 27, 2026 11:34
@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-8 branch from 7e9e48c to a7df108 Compare November 27, 2026 11:37
@mattzcarey
mattzcarey changed the base branch from slim/harness-A-successors-2 to main November 27, 2026 11:39
@mattzcarey
mattzcarey marked this pull request as draft November 27, 2026 11:40
@mattzcarey
mattzcarey force-pushed the slim/harness-A-successors-8 branch from a7df108 to 6e3a02a Compare November 27, 2026 11:43
@mattzcarey
mattzcarey marked this pull request as ready for review November 27, 2026 11:52
…eal resets, each after progress, go past maxAttempts and stop at maxInterruptedAttempts
…inished on its new branch, the earlier answer kept
…set while onChatRecovery runs re-runs it, with no terminal
… on the active branch, continue:false runs no model call, the interrupted-attempts bound is exact; the classifier tests are named in the rows
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.

1 participant