fix(agents): clear stale CLI session binding for all FailoverError reasons (#77089)#77385
fix(agents): clear stale CLI session binding for all FailoverError reasons (#77089)#77385hclsys wants to merge 2 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Summary Reproducibility: yes. Source inspection gives a high-confidence path: current main only clears stale CLI bindings for Real behavior proof Next step before merge Security Review findings
Review detailsBest possible solution: Keep the store cleanup for every resumed-session Do we have a high-confidence way to reproduce the issue? Yes. Source inspection gives a high-confidence path: current main only clears stale CLI bindings for Is this the best way to solve the issue? No. The cleanup boundary is right, but retrying timeout/unknown from Full review comments:
Overall correctness: patch is incorrect What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against c3a0fb9325c9. |
This comment was marked as low quality.
This comment was marked as low quality.
…asons (openclaw#77141) Previously, `attempt-execution.ts` only cleared the CLI session store entry when the FailoverError reason was session_expired, timeout, or unknown. Auth/billing errors skipped the clear, so the next turn would try to resume a dead CLI session and fail again. Now the binding is cleared for any FailoverError with an active binding. Recoverable reasons (session_expired, timeout, unknown) still retry fresh; non-recoverable reasons (auth, billing, rate_limit) rethrow immediately so the caller can surface the real error to the user. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
P2: add timeout and unknown recovery tests to prove cleared binding + fresh retry behavior, matching the existing session_expired test pattern. Also tighten comment in attempt-execution.ts to clarify the retry logic. P3: fix changelog to reference openclaw#77385 (this PR) and openclaw#77089 (bug), not the closed unmerged openclaw#77141. 19/19 tests pass. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Problem
attempt-execution.tsonly cleared the persisted CLI session binding from the store whenerr.reason === "session_expired". When a FailoverError with reasonauth,billing, orrate_limitwas thrown (either as the primary error or as a secondary error aftercli-runner.ts's internalsession_expiredretry), the stale binding was left in the store. The next turn would try to resume the same dead CLI session and fail again.Fix
Clear the stale binding unconditionally for any
FailoverErrorthat has anactiveCliSessionBinding. Then:session_expired,timeout,unknown): clear binding + retry with a fresh sessionauth,billing,rate_limit): clear binding + rethrow immediately so the caller surfaces the real errorThis also covers the case where
cli-runner.ts's internal session_expired retry succeeds with a fresh session but fails on a subsequent FailoverError (e.g. auth):attempt-execution.tsreceives the secondary error, correctly clears the original stale binding, and rethrows.Changes
src/agents/command/attempt-execution.ts: widen the FailoverError gate fromsession_expired-only to any FailoverError; add rethrow-without-retry path for non-recoverable reasonssrc/agents/command/attempt-execution.cli.test.ts: add test for non-recoverable path (authreason) — verifies binding is cleared (prevents dead-session resume) but no retry is attemptedCHANGELOG.md: entry for fix(agents): clear stale CLI session on any FailoverError, not only session_expired #77141Test
17/17 pass.
0 errors.
Fixes #77089.
Real behavior proof
FailoverErrorreason before rethrowing non-recoverable errors, so the next CLI turn does not retry a dead session id.fix/77089-cli-session-failover-v2after rebasing ontoorigin/main9c4a335007; Node/Vitest project runner from this repository.pnpm test src/agents/command/attempt-execution.cli.test.tsFailoverErrorreasons.