Repository navigation
fix: prevent internal recovery errors after queued turns - #164656
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. |
|
Codex review: blocked before merge. Reviewed October 5, 2026, 2:15 PM ET / 18:15 UTC (Revision 5). ClawSweeper reviewWhat this changesThe PR lets queued turns inherit an interrupted Control UI recovery record, preserves channel recovery tracking, and replaces internal ownership errors with conversation-change guidance. Merge readiness⛔ Blocked before merge - 1 item remains The prior handoff-refusal and channel-tracking findings are resolved. No remaining introduced correctness defect was found, and current main still lacks this repair. The Teams discussion identifies broader channel contention that this PR does not fully address. Priority: P2 Review scores
Verification
How this fits togetherReply admission connects incoming chat turns to durable session recovery records before agent execution. Those records subsequently govern reply-hook checkpoints, restart recovery, and cleanup. flowchart TD
A[Incoming or queued turn] --> B[Read session recovery record]
B --> C[Check predecessor and ownership]
C --> D[Guarded session write]
D --> E[Agent execution and reply checkpoints]
C --> F[Conversation-change guidance]
D --> F
E --> G[Recovery settlement and cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +76, Tests +229. Total +305 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Mantis proof suggestionA Control UI queued-turn transcript would usefully corroborate the repaired user flow. A maintainer can ask Mantis to capture proof by posting this exact PR comment: Technical reviewBest possible solution: Keep recovery transfer in the existing guarded admission owner, while preserving broader active-channel contention as separate work. Do we have a high-confidence way to reproduce the issue? Yes, from source: a distinct queued turn encountering an aborted running Control UI claim reaches the generic rejection on current main. Runtime execution was not performed during this read-only review. Is this the best way to solve the issue? Yes. The patch repairs the existing admission owner and distinguishes a refused write from a committed handoff; expanding it to active channel predecessors would require a separate, evidenced repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 7e27d6cebec6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
|
We hit this exact queued-successor race in production on the Microsoft Teams channel, and as far as I can tell this PR's hand-off would not cover it, because it only applies to Control UI turns. Environment: What happens: a user sends a second message in a DM while the previous turn in that session is still running. Admission throws instead of queueing, the msteams debounce flush gives up, and the message is silently lost. There was no gateway restart: it was the same process throughout. In both cases Request: could the successor hand-off (or simply waiting on the active claim's lane) apply to channel turns too, not only Control UI? For channels, a typed error plus a "conversation changed" notice still drops the user's message, and most users don't resend. |
de6052b to
eb99858
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
eb99858 to
0e9a383
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…4656) * fix: keep restart recovery races out of user replies * fix: describe recovery contention accurately * fix: preserve channel recovery claim tracking * test: split recovery successor coverage * fix: reject refused recovery handoffs
What Problem This Solves
Fixes: a queued Control UI turn could expose an internal restart-recovery ownership error after the preceding run was interrupted.
User Impact
An interrupted run no longer strands its queued successor. If recovery ownership changes in a way that cannot be transferred safely, the user sees conversation-change guidance instead of an internal claim diagnostic or an inaccurate claim that the Gateway is restarting.
Why This Change Was Made
OpenClaw records durable recovery ownership for admitted turns so work and delivery can be reconciled if the Gateway later restarts. The incident itself was not caused by
openclaw updateor a Gateway restart: the process stayed on the same PID while the active model/run was aborted and another Control UI turn was already queued.The queued successor had been admitted in memory while the earlier run still owned the durable recovery record. When the successor began, admission treated that retained ownership as an impossible claim change and threw a generic error that was persisted verbatim as a failed-before-reply message.
This change transfers only an aborted, delivery-free Control UI recovery record to its queued successor in one guarded session-row update. Admission now distinguishes a committed handoff from a refused expected-state patch before adopting the returned row. A channel successor keeps the distinct recovery ID persisted for its ingress, so hook checkpoints, readiness checks, and cleanup all service the same claim. Other ownership changes use a typed lifecycle error handled at the reply boundary, keeping internal diagnostics in logs while telling the user that the conversation changed.
Evidence
pnpm test src/auto-reply/reply/restart-recovery-claim.successor.test.ts src/auto-reply/reply/restart-recovery-claim.test.ts src/auto-reply/reply/restart-recovery-claim.lifecycle.test.ts src/auto-reply/reply/agent-runner-core.test.ts --maxWorkers=1— 59 tests passed in 76.61s.pnpm test src/gateway/server.chat.acp-completion.test.ts --maxWorkers=1— 12 tests passed in 61.15s after rebasing onto the upstream sharing-fence fix.pnpm test src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts --maxWorkers=1— 222 tests passed; two active-steering queue assertions outside this PR's changed paths failed on the earlier base. The recovery-admission regression in this file passed.pnpm check:changed— passed on the final source, including line-cap ratchets, production/test typechecks, lint, dead exports, import cycles, and database guards.fba69b0f817; no actionable findings.