fix(cli): stop stale session retry loops after failover#106284
fix(cli): stop stale session retry loops after failover#106284gangcaiyoule wants to merge 1 commit into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 13, 2026, 7:17 AM ET / 11:17 UTC. Summary PR surface: Source +50, Tests +224. Total +274 across 6 files. Reproducibility: yes. at source level: current main retries an expired CLI session fresh without clearing the persisted binding, so the next turn can select the same stale ID again. A real current-main gateway reproduction was not supplied in the PR evidence. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Port the expected-session compare-and-clear invariant onto current main's storage-neutral session accessor and canonical direct/queued CLI dispatch paths, then prove durable cleanup and successful continuation with a real expired-session failover while also proving that concurrent replacement and deletion remain untouched. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main retries an expired CLI session fresh without clearing the persisted binding, so the next turn can select the same stale ID again. A real current-main gateway reproduction was not supplied in the PR evidence. Is this the best way to solve the issue? Yes in principle: an atomic expected-session compare-and-clear before authorizing the fresh retry is the narrowest concurrency-safe fix. The submitted branch still needs to be ported to current main's storage accessor and execution topology before that judgment applies to the merge result. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4b6575636fd4. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +50, Tests +224. Total +274 across 6 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
@gangcaiyoule thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward. Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive. Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it. |
Closes #97887
AI-assisted: implemented and reviewed with Codex.
What Problem This Solves
Fixes an issue where CLI-backed turns could keep reusing an invalid session ID after a recoverable failover. Because the stale binding remained in session state, later turns could repeatedly resume the same broken CLI session instead of recovering with a fresh one.
Why This Change Was Made
The existing CLI runner already supports a guarded fresh-session retry, but the direct reply and queued follow-up dispatch paths did not clear their stored binding before that retry. This change wires both paths to an atomic compare-and-clear helper. It clears only the expected stale CLI session across current memory and persistence, refuses to overwrite a newer concurrent binding, and does not recreate a session deleted during the failed attempt.
User Impact
Users with Claude CLI or another CLI backend can recover from an expired or otherwise retryable stale session without entering a repeated failover loop. Concurrent session resets or replacements remain protected.
Evidence
The added regression coverage verifies matching stale-state cleanup, protection of a newer persisted binding, missing-row lifecycle isolation, direct reply recovery, and queued follow-up recovery.
I understand the compare-and-clear behavior and verified that it only authorizes a fresh retry after the expected persisted stale binding was removed.