Repository navigation
fix: preserve interrupted turns when new messages arrive - #170647
Conversation
Keep durable recovery custody during terminal session reuse so reply admission resumes the interrupted source before a new visible input. Add a deterministic regression for the scheduled orphan recovery failure.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: needs maintainer review before merge. What this changesPreserves an interrupted turn’s recovery claim when a new message reuses a failed, timed-out, or killed session. Example: A failed session retains interrupted-run and accepted-input recovery IDs when the user sends “Then verify the new request.”
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still clears interrupted recovery custody during terminal-session reuse, and this focused patch fixes that path without an actionable correctness finding. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSession preparation normalizes reusable terminal sessions before reply admission; reply admission consumes retained recovery markers to resume interrupted work through the existing recovery owner. flowchart TD
A[New visible message] --> B[Chat admission]
B --> C[Orphan reconciliation]
C --> D[Terminal session reuse]
D --> E[Reply admission]
E --> F[Existing recovery owner]
F --> G[Interrupted turn then new turn]
Technical reviewBest possible solution: Retain interrupted custody in the existing session-reuse owner and let existing reply admission resume it before accepting the next turn. Do we have a high-confidence way to reproduce the issue? Source establishes the path from failed orphan reconciliation through destructive terminal reuse to missed recovery admission; the body also reports a deterministic pre-fix failure, but no reproduction was executed during this read-only review. Is this the best way to solve the issue? The patch repairs the producer of lost custody using the canonical predicate, preserves ordinary terminal cleanup, and adds no competing recovery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3c53176667ae. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +6, Tests +16, Docs +3. Total +25 across 3 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
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 October 13, 2026, 3:24 AM ET / 07:24 UTC. |
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Keep durable recovery custody during terminal session reuse so reply admission resumes the interrupted source before a new visible input. Add a deterministic regression for the scheduled orphan recovery failure. (cherry picked from commit c47a8be)
…0647) Keep durable recovery custody during terminal session reuse so reply admission resumes the interrupted source before a new visible input. Add a deterministic regression for the scheduled orphan recovery failure.
…0647) Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Fixes interrupted chat recovery being skipped when a new visible message arrives before background recovery starts.
User Impact
Interrupted work keeps its recovery claim until recovery resumes it, so a new message cannot silently consume the old request as ordinary conversation history. Ordinary failed sessions without recovery custody still recover in place. No configuration or schema change is required.
Why This Change Was Made
Orphan reconciliation intentionally retains a failed outcome while marking its delivery claim interrupted. Terminal-session reuse then cleared the interruption flag and delivery/source IDs before reply admission could resume that work. Background recovery could win the race and hide the defect.
Extend the existing terminal-reuse protection with the canonical recovery-claim predicate. Add a deterministic regression beside the existing four-case Gateway recovery test; its assertions and timing limits remain unchanged. Document the recovery ordering. Production is +6 lines: the existing owner needs this additional predicate, with no new state or recovery path.
Evidence
The existing recovery test failed at the provider-count assertion in scheduled main runs 38334375513 / job 115091148557 and 38339144048 / job 115106094655: expected two requests, received one containing both messages.
New regression:
preserves interrupted recovery custody when reusing a failed session. It failed on unchanged production by clearingabortedLastRunand both delivery/source IDs. Command:CI=1 OPENCLAW_VITEST_WORKER_CACHE=1 node scripts/run-vitest.mjs src/gateway/server.chat.orphaned-recovery.test.ts --maxWorkers=1 -t 'preserves interrupted recovery custody'. Case: 43 ms; command: 235.02 s, mostly cold transformation/preparation.The original 25-file replay was stopped during cold Gateway setup without a verdict; the isolated original case also hit a setup timeout. Neither is claimed as a reproduction or passing proof. The nearby database-admission diagnostic is not claimed fixed.
Changed-file Oxlint: zero diagnostics across both TypeScript files. Oxfmt and
git diff --check: passed. Deslop: clean.Prescribed Codex autoreview: scoped-clean through P2; no accepted/actionable findings. Hosted Codex review also completed without suggestions. ClawSweeper has acknowledged the PR but has posted no code findings as of closeout.
PR CI is the test gate. At head
798c78243a8e8995c3be46057e9dfaf4c68247ba, job 115133100497 passed the new custody regression (7 ms) and the unchanged four-case Gateway recovery test (21.539 s). Itsagentic-control-plane-agent-chat-hosted-4shard passed both tests in 34.01 s. Run 38347696342 completed: all PR test, lint, and production/test typecheck jobs passed. There were 36 successful jobs, 25 skips, and two failures: the inherited asset check below and the aggregate CI gate reporting that failure.Live Gateway/Crabbox/Testbox proof, local typechecks, broad local suites, and production-reverted negative controls were intentionally skipped per maintainer policy. Only the lane's focused reproduction exception was used.
Inherited CI failure: PR build-artifacts job 115133099887 and latest scheduled main run 38347821426 / job 115133356342 both fail with the same generated
extensions/workboard/openclaw.plugin.jsonmismatch. This PR does not change the Workboard source or manifest.