Repository navigation
fix: a stalled turn that already answered posts a second answer or a retry notice - #162756
Conversation
|
🦞👀 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. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. Reviewed October 1, 2026, 11:14 AM ET / 15:14 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR prevents recovery answers and retry notices after a completed message-tool reply, while restoring recovery eligibility when newer steered input is accepted. Merge readiness✅ Ready for maintainer review This remains a useful, focused fix: current main still treats an already answered message-tool turn as eligible for stalled-turn recovery. No blocking correctness finding remains, and the recorded Telegram proof covers the unchanged production code. Priority: P1 Review scores
Verification
How this fits togetherReply operations track the lifecycle of incoming chat turns. Message-tool delivery and accepted steering update that operation, which dispatch and follow-up delivery consult when deciding whether a stalled turn still needs an answer. flowchart TD
A[Incoming chat turn] --> B[Reply operation]
C[Completed source reply] --> B
D[Accepted newer input] --> B
B --> E[Stall recovery decision]
E --> F[Already answered: stay quiet]
E --> G[Unanswered: recovery or notice]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +18, Tests +29. Total +47 across 10 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep completed-source delivery on the existing reply-operation owner so recovery answers only outstanding input. Do we have a high-confidence way to reproduce the issue? Yes: complete a final source message-tool send, hold the subsequent model request, and let the watchdog expire the turn. Current-main source establishes the missing delivery check, and the contributor records this failing live sequence. Is this the best way to solve the issue? Yes: extending the existing operation and shared recovery predicate is a narrow repair, and accepted steering correctly invalidates an earlier answer. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 43873ce187b1. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
50a09f1 to
12a2cf0
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Landed after the full landing checklist on the exact head: adversarial review LAND, ClawSweeper ready, live before/after proof in the PR body, full CI green, bounded cost, and no new user-visible messages. |
…retry notice (openclaw#162756) ## What Problem This Solves Fixes: when a chat turn has already answered through the message tool and then stalls on a later model request, stuck-session recovery treats it as unanswered. It starts a recovery turn, which posts a second, redundant answer, or, if that also stalls, the "Please try again" notice. ## User Impact After a turn's final message-tool answer reaches the chat, a later stall stays quiet: no recovery turn, no second message, no retry notice. Progress messages (`final: false`) don't count as an answer, so a turn that only said "working on it" still recovers as before. In message-tool-only mode (Slack quiet mode), where every visible reply is a message-tool send, this keeps a stall after the answer from posting the last-resort notice, which bypasses quiet-mode suppression. ## Why This Change Was Made openclaw#161069 decides between recovery and the notice with `isReplyOperationStalledBeforeOutput(operation)`, which checked only the stall reason. An adversarial review of openclaw#161069 found that this ignores source delivery that already happened. The run result does carry the delivery evidence, but dispatch makes the notice/recovery decision as soon as the watchdog expires the reply operation, before the aborted run returns its result. A live run confirmed that ordering (`cause=skipped:reply_operation_aborted` before the fallback chain settles). So the reply operation, which owns the turn's lifecycle, now owns the fact as well. A successful final message-tool send to the turn's exact source (the existing `messageDelivery.sourceReplyDelivered` condition: settled, not partial, not dry-run, `final` not `false`, current source) marks the active operation `sourceReplyDelivered`. The single predicate reads it, so dispatch, follow-up delivery and any future caller share one rule. A user message steered into the same operation after that answer reopens it. Steer acceptance has one owner on the operation (`markSteeredInputAccepted`, which replaces the audio-only `markAcceptedSteeredInboundAudio` from openclaw#95596; its audio flag is unchanged). It clears the fact, so the newer request still recovers if the turn then stalls. Hermes (sibling framework) keeps one per-turn reply owner and never re-answers after a delivered reply. Its inactivity timeout only reports through that owner. ## Bounded cost This only removes work. No new model calls, runs or messages. A stalled turn that already answered starts no recovery turn (one model run fewer). Recovery stays at most once per stalled turn on every surface, unchanged. ## Evidence - **Telegram Test Server, live model.** `telegram-e2e-userbot` skill, Convex-leased credential, real QA user in a DM, `openai/gpt-6-astra` through a proof-only local proxy in front of the real OpenAI API, QA stuck-session bound 30 s. A live model can't be made to stall, so the proxy holds open the first model request that follows a completed `message` tool call. Everything else reaches the live API unchanged. The QA user sends: "Use the message tool to send me the answer to 17*23 as just the number. After that message is sent, you are done: send nothing else." - **Before (`origin/main` 02f46a6):** the model sends `391` through the message tool. The next request is held, and stuck recovery aborts the turn at age 47 s. A recovery request carrying the stall guidance then goes to the live model, and the chat gets a second message, "Already sent: 391.". SUT messages: `391`, `Already sent: 391.` - **After (exact head `50a09f1`):** the model sends `391` through the message tool, the next request is held, and stuck recovery aborts the turn at age 49 s. There's no recovery request, and the chat shows only `391`. No second message and no notice. The earlier run on `fe6eed9` matched it: same `391` send, held request, and stuck abort (age 48 s). There's no recovery request, and the chat shows only `391`. No second message and no notice. - Both runs also show the existing "Working" progress row, which is unchanged. - **Second message during the stall (exact head `50a09f1`):** the scenario sends the 17*23 request, then "Also, what is 19*21? Reply with just the number." 30 s later, while the post-answer request is held. - Live, the second message was queued as its own turn rather than steered (`queueDepth=1`), because the active run doesn't take steering after its answer. - The first turn's stall (age 75 s) started no recovery. The queued turn then ran and stalled too (age 58 s), and its recovery answered it. - Chat: `391`, then `399`. One guided recovery request, for the unanswered second message only. - The steered-into-the-same-operation variant isn't reachable in this flow, so it's covered by the real `runReplyAgent` steer test. - **Regression tests:** - `dispatch-from-config.terminal-recovery.test.ts`: a new case marks the active operation answered, then lets the watchdog expire it while the run is still pending, which is the real order. It expects no notice and no continuation. It fails on `main`. - `message-tool-execution.test.ts`: the existing eligibility table now also asserts that only an eligible final source send marks the operation. Failures, partial sends, dry runs, `final: false` and other targets don't mark it. - The same table has a case where an answer is followed by a steered input. It expects one continuation. - `agent-runner.media-paths.test.ts`: the real steer path through `runReplyAgent` clears an earlier answer. - Focused suites pass, including `reply-run-registry`, `dispatch-from-config` and `message-tool-execution`. - One-worker wall times (`pnpm test <file> --maxWorkers=1`, real / Vitest duration): `dispatch-from-config.terminal-recovery.test.ts` 27 s / 23.8 s (27 tests); `message-tool-execution.test.ts` 23 s / 20.3 s (76 tests); `agent-runner.media-paths.test.ts` 27 s / 23.3 s (21 tests). Transform dominates (75–80%); each is under 30 s. - `node scripts/check-changed.mjs` passes. LOC vs `origin/main`: production +25/−7, tests +33/−6. No new user-visible messages. This only removes a redundant answer and an incorrect notice. No overlap with Pash/Sarah changes on the touched files. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: when a chat turn has already answered through the message tool and then stalls on a later model request, stuck-session recovery treats it as unanswered. It starts a recovery turn, which posts a second, redundant answer, or, if that also stalls, the "Please try again" notice.
User Impact
After a turn's final message-tool answer reaches the chat, a later stall stays quiet: no recovery turn, no second message, no retry notice. Progress messages (
final: false) don't count as an answer, so a turn that only said "working on it" still recovers as before. In message-tool-only mode (Slack quiet mode), where every visible reply is a message-tool send, this keeps a stall after the answer from posting the last-resort notice, which bypasses quiet-mode suppression.Why This Change Was Made
#161069 decides between recovery and the notice with
isReplyOperationStalledBeforeOutput(operation), which checked only the stall reason. An adversarial review of #161069 found that this ignores source delivery that already happened.The run result does carry the delivery evidence, but dispatch makes the notice/recovery decision as soon as the watchdog expires the reply operation, before the aborted run returns its result. A live run confirmed that ordering (
cause=skipped:reply_operation_abortedbefore the fallback chain settles).So the reply operation, which owns the turn's lifecycle, now owns the fact as well. A successful final message-tool send to the turn's exact source (the existing
messageDelivery.sourceReplyDeliveredcondition: settled, not partial, not dry-run,finalnotfalse, current source) marks the active operationsourceReplyDelivered. The single predicate reads it, so dispatch, follow-up delivery and any future caller share one rule.A user message steered into the same operation after that answer reopens it. Steer acceptance has one owner on the operation (
markSteeredInputAccepted, which replaces the audio-onlymarkAcceptedSteeredInboundAudiofrom #95596; its audio flag is unchanged). It clears the fact, so the newer request still recovers if the turn then stalls.Bounded cost
This only removes work. No new model calls, runs or messages. A stalled turn that already answered starts no recovery turn (one model run fewer). Recovery stays at most once per stalled turn on every surface, unchanged.
Evidence
telegram-e2e-userbotskill, Convex-leased credential, real QA user in a DM,openai/gpt-6-astrathrough a proof-only local proxy in front of the real OpenAI API, QA stuck-session bound 30 s. A live model can't be made to stall, so the proxy holds open the first model request that follows a completedmessagetool call. Everything else reaches the live API unchanged. The QA user sends: "Use the message tool to send me the answer to 17*23 as just the number. After that message is sent, you are done: send nothing else."origin/maind06974d): the model sends391through the message tool. The next request is held, and stuck recovery aborts the turn at age 47 s. A recovery request carrying the stall guidance then goes to the live model, and the chat gets a second message, "Already sent: 391.". SUT messages:391,Already sent: 391.50a09f1): the model sends391through the message tool, the next request is held, and stuck recovery aborts the turn at age 49 s. There's no recovery request, and the chat shows only391. No second message and no notice. The earlier run onfe6eed9matched it: same391send, held request, and stuck abort (age 48 s). There's no recovery request, and the chat shows only391. No second message and no notice.50a09f1): the scenario sends the 1723 request, then "Also, what is 1921? Reply with just the number." 30 s later, while the post-answer request is held.queueDepth=1), because the active run doesn't take steering after its answer.391, then399. One guided recovery request, for the unanswered second message only.runReplyAgentsteer test.dispatch-from-config.terminal-recovery.test.ts: a new case marks the active operation answered, then lets the watchdog expire it while the run is still pending, which is the real order. It expects no notice and no continuation. It fails onmain.message-tool-execution.test.ts: the existing eligibility table now also asserts that only an eligible final source send marks the operation. Failures, partial sends, dry runs,final: falseand other targets don't mark it.agent-runner.media-paths.test.ts: the real steer path throughrunReplyAgentclears an earlier answer.reply-run-registry,dispatch-from-configandmessage-tool-execution.pnpm test <file> --maxWorkers=1, real / Vitest duration):dispatch-from-config.terminal-recovery.test.ts27 s / 23.8 s (27 tests);message-tool-execution.test.ts23 s / 20.3 s (76 tests);agent-runner.media-paths.test.ts27 s / 23.3 s (21 tests). Transform dominates (75–80%); each is under 30 s.node scripts/check-changed.mjspasses.LOC vs
origin/main: production +25/−7, tests +33/−6.No new user-visible messages. This only removes a redundant answer and an incorrect notice.