Repository navigation
fix(agents): stop utility fallbacks when the caller cancels its own attempt - #207262
Conversation
…ttempt A utility task's currency guard (Activity recap, titles, transcript summaries) throws when its own work goes stale, while the caller's abort signal stays live. The fallback runner only treats an aborted signal as a cancel, so it counted the throw as a model failure and ran the next utility model. runUtilityCompletion now aborts a linked signal with the guard's error, so the chain stops on the existing caller-cancel fact.
…llback chain Its custom runner called the raw caller guard, so the throw bypassed runUtilityCompletion's cancel signal.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. What this changesThe PR stops utility model fallbacks when the caller's existing stale-task guard throws. Example: A title request uses openai/gpt-mini with openai/utility-backup configured, and its owner retires during completion.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it addresses a concrete cancellation defect in the shared utility fallback path, and source review found no introduced correctness bugs. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherUtility callers supply model settings, cancellation signals, and lifecycle guards; the shared completion adapter runs candidates through the model fallback owner and returns a result or terminal error. flowchart TD
A[Utility task owner] --> B[Utility completion adapter]
B --> C[Model fallback runner]
C --> D[Isolated completion]
D --> E[Caller lifecycle guard]
E --> F[Local cancellation signal]
F --> C
Technical reviewBest possible solution: Keep cancellation translation in the existing utility adapter and have custom runners consume its candidate guard. Do we have a high-confidence way to reproduce the issue? Main's guard-error and signal paths establish the defect, supported by the author's reported regression failures; no target code was executed during this read-only review. Is this the best way to solve the issue? The patch fixes the cancellation classification at its shared owner without changing model-error classification or adding another retry mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d8c456001c10. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +20, Tests +86. Total +106 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 28, 2026, 12:38 AM ET / 05:38 UTC. |
…ttempt (openclaw#207262) ## Problem A utility task that cancels its own work makes the fallback chain run the next utility model. - The Activity recap, titles and transcript summaries pass a currency guard (`assertCurrent`) to `runUtilityCompletion`. The guard throws when the task's own work goes stale: the recap's session changed or a newer recap took over ("Activity recap lifecycle or utility model changed"), the title owner retired, or a newer transcript capture owner took the lane. - When it throws, the caller's abort signal is still live. The fallback runner's only cancel fact is that signal (`resolveChainStopReason`, `model-fallback-attempt.ts`), so it counts the throw as a model failure and starts the next utility model. - Real-user log signature (a production team Gateway, 4.35 h): 72 `model_fallback_decision candidate_failed` on the utility primary with the recap's self-cancel error; 19 of them went on to a configured utility fallback that the runtime does not offer, each failing with `model_not_found` and a "Activity recap deferred" line. ## Change `runUtilityCompletion` (the one owner every utility user goes through) wraps the caller's `assertCurrent` on the fallback path. When it throws, a local controller is aborted with that same error and the error is rethrown. The chain receives `AbortSignal.any([caller, local])`, so the existing caller-cancel stop applies. No error-name or message match, no new error class, no runner change. - A real model failure with a current caller still falls back (test). - The no-fallback path is unchanged: with one candidate there is no next model to stop. ## User impact - Recaps, titles, transcript notes and composer predictions that go stale stop at once instead of trying the next utility model, and a stale recap no longer produces a fallback `model_not_found` error or a retry delay. The chain logs one `model fallback chain stopped reason=caller_signal_aborted` line instead. - Not changed: progress narration and the session observer already cancel through their abort signal. ## Evidence | Test | Main | This PR | |---|---|---| | `utility-completion.runtime.test.ts`: guard throws the recap's `AbortError`, caller signal live | 3 model calls | 1 | | `conversation-label-generator.test.ts`: title owner retires during the utility attempt | `gpt-mini`, `utility-backup` | `gpt-mini` | | `summary-model.test.ts`: a newer capture owner takes the summary lane during the attempt (real lane-generation guard) | `utility-test-model`, `utility-backup` | `utility-test-model` | | Guard present, model fails with a timeout | falls back | falls back | - Each red was run with main's `utility-completion.ts` against the new tests; all green with the change. The three touched test files pass in full (19, 21 and 18 tests). - `tsgo:core`, core test typecheck and oxlint on the touched files are clean. - Adversarial review: land. Its one gap is taken: composer prediction's custom runner called the raw caller guard (`composer-prediction-completion.ts`), so its throw bypassed the wrapper; it now calls the candidate's guard. The review also confirmed that the wrapper sees only the caller's guard: the operator-model check, the timeout and the closed check inside isolated completion still fall back as before. - Local review on head `5bcb1ab3` (after merging main for openclaw#207259): patch is correct, 0 findings, security cleared. - Live proof gap (named): the self-cancel is a timing race (the session changes or a newer task takes over during the model call), so an isolated Gateway run cannot trigger it on demand. The tests drive the real guards (recap error shape, the title owner's guard, the transcript lane generation) through the real fallback runner. Production confirmation is the post-deploy log count: the recap self-cancel fallback decisions should go from 72 per 4.35 h to 0. Co-authored-by: Ayaan Zaidi <[email protected]>
…ttempt (#207262) ## Problem A utility task that cancels its own work makes the fallback chain run the next utility model. - The Activity recap, titles and transcript summaries pass a currency guard (`assertCurrent`) to `runUtilityCompletion`. The guard throws when the task's own work goes stale: the recap's session changed or a newer recap took over ("Activity recap lifecycle or utility model changed"), the title owner retired, or a newer transcript capture owner took the lane. - When it throws, the caller's abort signal is still live. The fallback runner's only cancel fact is that signal (`resolveChainStopReason`, `model-fallback-attempt.ts`), so it counts the throw as a model failure and starts the next utility model. - Real-user log signature (a production team Gateway, 4.35 h): 72 `model_fallback_decision candidate_failed` on the utility primary with the recap's self-cancel error; 19 of them went on to a configured utility fallback that the runtime does not offer, each failing with `model_not_found` and a "Activity recap deferred" line. ## Change `runUtilityCompletion` (the one owner every utility user goes through) wraps the caller's `assertCurrent` on the fallback path. When it throws, a local controller is aborted with that same error and the error is rethrown. The chain receives `AbortSignal.any([caller, local])`, so the existing caller-cancel stop applies. No error-name or message match, no new error class, no runner change. - A real model failure with a current caller still falls back (test). - The no-fallback path is unchanged: with one candidate there is no next model to stop. ## User impact - Recaps, titles, transcript notes and composer predictions that go stale stop at once instead of trying the next utility model, and a stale recap no longer produces a fallback `model_not_found` error or a retry delay. The chain logs one `model fallback chain stopped reason=caller_signal_aborted` line instead. - Not changed: progress narration and the session observer already cancel through their abort signal. ## Evidence | Test | Main | This PR | |---|---|---| | `utility-completion.runtime.test.ts`: guard throws the recap's `AbortError`, caller signal live | 3 model calls | 1 | | `conversation-label-generator.test.ts`: title owner retires during the utility attempt | `gpt-mini`, `utility-backup` | `gpt-mini` | | `summary-model.test.ts`: a newer capture owner takes the summary lane during the attempt (real lane-generation guard) | `utility-test-model`, `utility-backup` | `utility-test-model` | | Guard present, model fails with a timeout | falls back | falls back | - Each red was run with main's `utility-completion.ts` against the new tests; all green with the change. The three touched test files pass in full (19, 21 and 18 tests). - `tsgo:core`, core test typecheck and oxlint on the touched files are clean. - Adversarial review: land. Its one gap is taken: composer prediction's custom runner called the raw caller guard (`composer-prediction-completion.ts`), so its throw bypassed the wrapper; it now calls the candidate's guard. The review also confirmed that the wrapper sees only the caller's guard: the operator-model check, the timeout and the closed check inside isolated completion still fall back as before. - Local review on head `5bcb1ab3` (after merging main for #207259): patch is correct, 0 findings, security cleared. - Live proof gap (named): the self-cancel is a timing race (the session changes or a newer task takes over during the model call), so an isolated Gateway run cannot trigger it on demand. The tests drive the real guards (recap error shape, the title owner's guard, the transcript lane generation) through the real fallback runner. Production confirmation is the post-deploy log count: the recap self-cancel fallback decisions should go from 72 per 4.35 h to 0. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit e2fa67a) Release adaptation: Combine the release transcript summary helpers with the upstream cancel-through-persistence regression imports. Co-authored-by: RomneyDa <[email protected]>
Release adaptation: Keep current recap lease and profile checks, return deliberate role refusals without retry, and snapshot only the admitted model restriction for each observer run. Adapt role regression fixtures to the stable admission API. Companion audit: #206962 already committed as the ordered companion. #207774 plugin generation handling is already in stable. #207262 cancellation, #205607 title fallback, and #208460 provider routing are separate existing behaviors; #207247 is follow-up documentation. (cherry picked from commit 6d8d1f5) Co-authored-by: RomneyDa <[email protected]>
…ttempt (#207262) A utility task that cancels its own work makes the fallback chain run the next utility model. - The Activity recap, titles and transcript summaries pass a currency guard (`assertCurrent`) to `runUtilityCompletion`. The guard throws when the task's own work goes stale: the recap's session changed or a newer recap took over ("Activity recap lifecycle or utility model changed"), the title owner retired, or a newer transcript capture owner took the lane. - When it throws, the caller's abort signal is still live. The fallback runner's only cancel fact is that signal (`resolveChainStopReason`, `model-fallback-attempt.ts`), so it counts the throw as a model failure and starts the next utility model. - Real-user log signature (a production team Gateway, 4.35 h): 72 `model_fallback_decision candidate_failed` on the utility primary with the recap's self-cancel error; 19 of them went on to a configured utility fallback that the runtime does not offer, each failing with `model_not_found` and a "Activity recap deferred" line. `runUtilityCompletion` (the one owner every utility user goes through) wraps the caller's `assertCurrent` on the fallback path. When it throws, a local controller is aborted with that same error and the error is rethrown. The chain receives `AbortSignal.any([caller, local])`, so the existing caller-cancel stop applies. No error-name or message match, no new error class, no runner change. - A real model failure with a current caller still falls back (test). - The no-fallback path is unchanged: with one candidate there is no next model to stop. - Recaps, titles, transcript notes and composer predictions that go stale stop at once instead of trying the next utility model, and a stale recap no longer produces a fallback `model_not_found` error or a retry delay. The chain logs one `model fallback chain stopped reason=caller_signal_aborted` line instead. - Not changed: progress narration and the session observer already cancel through their abort signal. | Test | Main | This PR | |---|---|---| | `utility-completion.runtime.test.ts`: guard throws the recap's `AbortError`, caller signal live | 3 model calls | 1 | | `conversation-label-generator.test.ts`: title owner retires during the utility attempt | `gpt-mini`, `utility-backup` | `gpt-mini` | | `summary-model.test.ts`: a newer capture owner takes the summary lane during the attempt (real lane-generation guard) | `utility-test-model`, `utility-backup` | `utility-test-model` | | Guard present, model fails with a timeout | falls back | falls back | - Each red was run with main's `utility-completion.ts` against the new tests; all green with the change. The three touched test files pass in full (19, 21 and 18 tests). - `tsgo:core`, core test typecheck and oxlint on the touched files are clean. - Adversarial review: land. Its one gap is taken: composer prediction's custom runner called the raw caller guard (`composer-prediction-completion.ts`), so its throw bypassed the wrapper; it now calls the candidate's guard. The review also confirmed that the wrapper sees only the caller's guard: the operator-model check, the timeout and the closed check inside isolated completion still fall back as before. - Local review on head `5bcb1ab3` (after merging main for #207259): patch is correct, 0 findings, security cleared. - Live proof gap (named): the self-cancel is a timing race (the session changes or a newer task takes over during the model call), so an isolated Gateway run cannot trigger it on demand. The tests drive the real guards (recap error shape, the title owner's guard, the transcript lane generation) through the real fallback runner. Production confirmation is the post-deploy log count: the recap self-cancel fallback decisions should go from 72 per 4.35 h to 0. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit e2fa67a) Release adaptation: exercise the same capture owner supersession with the stable utterance snapshot shape and public provider types. Later PR-number mentions are unrelated; no required follow-up. Co-authored-by: RomneyDa <[email protected]>
* refactor: prepare transcript speaker attribution once per snapshot * test: assert prepared transcript turns across the SQLite worker (cherry picked from commit 3990574) Release adaptation: retain stable provider and protocol types while sharing the existing persisted speaker roster across capped summary and Markdown presentation. No persisted schema changes. Release adaptation: integration conflict with 8e715d1 (#207262) resolved by preserving the capture-owner cancellation test and providing prepared snapshot turns for its store fixture. Co-authored-by: RomneyDa <[email protected]>
Problem
A utility task that cancels its own work makes the fallback chain run the next utility model.
assertCurrent) torunUtilityCompletion. The guard throws when the task's own work goes stale: the recap's session changed or a newer recap took over ("Activity recap lifecycle or utility model changed"), the title owner retired, or a newer transcript capture owner took the lane.resolveChainStopReason,model-fallback-attempt.ts), so it counts the throw as a model failure and starts the next utility model.model_fallback_decision candidate_failedon the utility primary with the recap's self-cancel error; 19 of them went on to a configured utility fallback that the runtime does not offer, each failing withmodel_not_foundand a "Activity recap deferred" line.Change
runUtilityCompletion(the one owner every utility user goes through) wraps the caller'sassertCurrenton the fallback path. When it throws, a local controller is aborted with that same error and the error is rethrown. The chain receivesAbortSignal.any([caller, local]), so the existing caller-cancel stop applies. No error-name or message match, no new error class, no runner change.User impact
model_not_founderror or a retry delay. The chain logs onemodel fallback chain stopped reason=caller_signal_abortedline instead.Evidence
utility-completion.runtime.test.ts: guard throws the recap'sAbortError, caller signal liveconversation-label-generator.test.ts: title owner retires during the utility attemptgpt-mini,utility-backupgpt-minisummary-model.test.ts: a newer capture owner takes the summary lane during the attempt (real lane-generation guard)utility-test-model,utility-backuputility-test-modelutility-completion.tsagainst the new tests; all green with the change. The three touched test files pass in full (19, 21 and 18 tests).tsgo:core, core test typecheck and oxlint on the touched files are clean.composer-prediction-completion.ts), so its throw bypassed the wrapper; it now calls the candidate's guard. The review also confirmed that the wrapper sees only the caller's guard: the operator-model check, the timeout and the closed check inside isolated completion still fall back as before.e0b861ed: patch is correct, 0 findings, security cleared.