Repository navigation
fix(agents): preserve CLI continuity for queued cold turns - #136644
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: blocked before merge. Reviewed September 2, 2026, 6:32 PM ET / 22:32 UTC. ClawSweeper reviewWhat this changesPreserves the accepted CLI session binding when a queued cold turn falls through to a successful fallback, while fencing persistence to the live session lifecycle and turn settlement. Merge readiness⛔ Blocked before merge - 3 items remain Keep open: the exact-head implementation addresses the prior accepted-fallback continuity concern, but it is not on current main and exact-head CI plus a refreshed runtime probe remain pending. Priority: P1 Review scores
Verification
How this fits togetherQueued agent turns use a stored CLI session binding to resume continuity after admission. This change classifies the accepted CLI result and commits its binding only while the admitted session and writer still own settlement. flowchart TD
Result[CLI candidate result] --> Classify[Classify accepted result]
Session[Admitted session lifecycle] --> Guard[Settlement commit guard]
Classify --> Guard
Guard --> Binding[Stored CLI session binding]
Binding --> NextTurn[Next queued cold turn]
Lifecycle[Abort or replacement] --> Guard
Before merge
Agent review detailsSecurityNone. PR surfaceSource +156, Tests +683. Total +839 across 39 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one guarded persistence owner with cached accepted-candidate classification, then complete exact-head CI and an isolated queued-fallback continuity probe. Do we have a high-confidence way to reproduce the issue? No high-confidence current-main runtime reproduction was run in this read-only review; the affected fallback path and its regression scenarios are directly defined by source and focused tests. Is this the best way to solve the issue? Yes: the branch records the accepted native binding at the lifecycle owner’s synchronous settlement edge instead of leaving command, reply, and cron paths to retain it independently. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 1703bd765298. LabelsLabel changes:
Label justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
Separate command native-session preservation from displayed fallback model preservation. Successful fallback candidates publish their continuation before the session lane releases, while heartbeat and explicitly preserved turns retain the prior native binding. Exercise the real outer fallback path followed by a queued cold command, and have result-classifier fixtures execute the candidate before reading its recorded classification.
|
Exact-head validation is complete for CI run 33689995303 is green. Changed checks, core/test types, type-aware lint, three dead-code scans, and the matching runtime/UI build passed. Branch review has no accepted findings after direct source validation; the proposed storeless-publication gap was rejected because the old writer also returned without a store path and production reply sessions supply a canonical path. The refreshed live proof uses a real isolated Gateway and Control UI with an explicitly synthetic one-shot CLI backend. Two direct Queue acceptance is not counted as delivery: both correlated assistant finals were received and displayed. Screenshots below are entirely synthetic. The previous reply-path cold-process proof remains in the PR body; this refreshed proof additionally covers the command-side fallback correction. The latest ClawSweeper rank-up moves—exact-head CI and refreshed fallback-to-queued-cold-turn proof—are now complete. |
|
Merged via squash.
|
…136644) * fix(agents): settle CLI continuity before session lane release * test(agents): use typed CLI provider in continuity fixture * style: satisfy CLI settlement lint checks * fix(agents): retain accepted fallback CLI continuity Separate command native-session preservation from displayed fallback model preservation. Successful fallback candidates publish their continuation before the session lane releases, while heartbeat and explicitly preserved turns retain the prior native binding. Exercise the real outer fallback path followed by a queued cold command, and have result-classifier fixtures execute the candidate before reading its recorded classification.


Related: #136423 (busy-parent subagent completion admission), #134186, #135192.
What Problem This Solves
Fixes an issue where users queueing another turn on a CLI-backed session could lose native conversation continuity when the next turn started in a fresh CLI process. It also prevents a retired or rejected run from overwriting the continuation that a later turn should use.
Why This Change Was Made
Native continuation now settles before the same-session admission lane releases, with the exact live placement/turn assertion carried to the existing synchronous store commit. Command, reply, and cron share that ownership rule; duplicate late writers and clear helpers are removed. Local OpenClaw session IDs remain distinct from native CLI IDs, and only the explicit native binding result is persisted.
Accepted fallback candidates may publish continuity. Explicit invalid-binding cleanup still works after abort while that exact owner remains live; closed/replaced owners cannot publish or clear. Cron stages the result until its guarded base commit succeeds so later finalization cannot resurrect a rejected write. Keeping all post-run accounting under the lane would instead risk deadlocking compaction, which can itself enter that lane. This changes no config, environment, database schema, stored representation, protocol, or dependency.
User Impact
Queued CLI turns resume the preceding accepted native conversation even without a warm CLI process. Aborted, replaced, or rejected candidates cannot silently poison later continuation. Embedded session rollover, provenance-preserved turns, explicit native invalidation, and compaction remain covered.
This is the separately scoped follow-up to #136423; it does not claim to repair the unrelated bootstrap migration, Telegram ingress, or Discord display-size allegations from the original reports. Thanks to Sean van der Walt (@svdwalt007), @Isitjustmefromparis, and @Tony-Clawbot for the reports that led to the admission and continuity investigation.
Evidence
Validated head:
c4102b45bdc5f43704e4af8987503f7e46550b6c. Exact-head CI is green; changed checks, types, lint, three dead-code scans, runtime/UI build, and the refreshed before/after Gateway fallback proof passed. Branch review completed with no accepted findings after direct source validation. The proposed storeless-publication gap was rejected: the old writer also returned without a store path, and normal reply sessions supply the canonical path.3893ade22c24d6c4c6964a4ff524ffb101b4ff20: the queued cold command received no native binding. The real Gateway/Control UI directagentRPC probe on that same immutable build also visibly returnedFALLBACK_COLD_RESUME_MISSING.0a0f0cc96b6d0221be7c3d264223cd00ec99eea8; later typed-fixture and mechanical changes were checked separately. The existing live transcript below is explicitly the previous3893ade22c24reply-path proof; the new head's direct-command fallback proof is linked above.Review correction and CI follow-up
ClawSweeper's accepted-fallback finding and both rank-up moves are addressed in
c4102b45bdc5f43704e4af8987503f7e46550b6c: native continuation no longer inherits provider/model display-preservation conditions, and the regression traverses the realrunEmbeddedAgentAttemptfallback owner before queueing the next cold command. Heartbeat and explicitly preserved turns still retain the original binding. This coupling also existed in the base commit's late writer; the change repairs it without attributing introduction to this PR or a contributor.The old CI head exposed three reply fixtures that bypassed candidate execution and therefore had no recorded classification; those fixtures now execute the candidate and pass without adding production reclassification. One unrelated Copilot cleanup test also failed: its real 5 ms deadline can expire before
createSessionstarts. Named follow-up: make that late-session cleanup fixture trigger its deadline after session creation starts using a controlled clock, not a larger timeout. This is a source-backed timing-flake inference, not a locally reproduced defect; the new-head CI run is now green.The original cold-process regression queued the second command before the first returned with no warm session registry; the second command received no native binding before the fix. That initial terminal output was captured, but no complete raw tee log was retained. Later full-log regressions cover cold invalidation, rejected fallback candidates, queue reset, exact-owner clear/fork writes, cron rejected-commit followed by finalization, and local/native ID separation. The real-builder scalar-ID test is a before/after correction of the proposed canonical owner, not an unchanged-main run. Introduction provenance is unknown; this PR does not attribute the defect to a particular contributor.
Final-head live fallback transcript (
c4102b45bdc5)The same real Gateway and Control UI flow that failed before the fallback correction now passes. An explicitly synthetic one-shot CLI backend uses existing plugin/auth contracts; two direct
agentRPC requests from the connected Control UI client each encounter primary capacity failure and complete through the fallback. No warm process, provider credentials, operator state, or product-source fixture changes were used.The verifier requires matching commit/build metadata and actual Control UI/Gateway handshake build IDs, correlated accepted and final RPC payloads, same-session assistant-final events, four one-shot processes, and exact native reuse. Queue acceptance alone is not delivery. Inspected synthetic-only before/after screenshots and full proof summary. The owned Gateway and browser exited cleanly, isolated state was removed, and the port was verified free. Latest ClawSweeper rank-up moves (exact-head CI and refreshed fallback trace) are complete.
Previous-head isolated live transcript (
3893ade22c24)Real Gateway, canonical session store, and Control UI; explicitly synthetic one-shot CLI dependency using the existing plugin backend and local synthetic-auth discovery contracts. No warm CLI session registry, credentials, operator state, or product source changes were used for the fixture. The first request used the normal composer; the second used the connected Control UI client's normal
chat.sendAPI withqueueMode: followupso it reached the Gateway while the first process was busy.Queued admission and execution have distinct run IDs; the Gateway's recorded
chat.send_timing.agentRunIdmapping connects the accepted second request to its actual assistant final. Queue acceptance alone is not counted as delivery. This live run verifies the user flow after the fix; the deterministic original-order regressions establish the pre-fix race. The parent PR separately contains the real Claude busy-parent completion/abort roundtrip.Production LOC: +479/-323 (net +156); tests/support: +989/-306 (net +683). Growth supplies the previously missing exact-owner synchronous commit contract and one recorded candidate-classification decision; removed late publication paths and consolidated clearing offset it. Existing continuity behavior is documented at https://docs.openclaw.ai/gateway/cli-backends.