Repository navigation
fix(agents): run embedded gateway fallback on a fresh session after abnormal close - #110226
Conversation
8d766f0 to
e77967b
Compare
|
Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 7:14 PM ET / 23:14 UTC. Summary PR surface: Source -6, Tests +24. Total +18 across 3 files. Reproducibility: no. high-confidence live reproduction was inspectable in this review. The submitted test and description make the gateway-accepted-then-1006-close path source-reproducible, but no current-main runtime trace was available. Review metrics: none identified. 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
Maintainer decision needed
Security Review detailsBest possible solution: Retain the fresh-session fallback boundary, then add redacted real gateway crash/restart evidence showing the original session is recovered only by the gateway while the CLI fallback runs under a distinct session key. Do we have a high-confidence way to reproduce the issue? No high-confidence live reproduction was inspectable in this review. The submitted test and description make the gateway-accepted-then-1006-close path source-reproducible, but no current-main runtime trace was available. Is this the best way to solve the issue? Unclear. Using a fresh fallback session matches the stated goal of preventing concurrent writers, but a maintainer must confirm the resulting recovery/session-continuity contract and see real crash-path evidence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d03b015ff475. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source -6, Tests +24. Total +18 across 3 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
|
|
Merged via squash.
|
What Problem This Solves
When the gateway is hard-killed (e.g. SIGKILL, WebSocket 1006 abnormal closure) while an
openclaw agentturn is in flight, the CLI's embedded fallback re-ran the agent locally reusing the same explicit session key. Meanwhile the relaunched gateway'smain-session-restart-recoveryalso resumes that same session — so two processes can drive one session concurrently across process boundaries (duplicate/conflicting transcript writes). The existing timeout fallback already used a distinctgateway-fallback-*session; the abnormal-close path did not.Why This Change Was Made
Found during the R4 whole-system QA campaign (restart/recovery stress, live keys, isolated gateways). Repro: start a long agent turn, SIGKILL the gateway mid-turn → CLI logs
EMBEDDED FALLBACKand enqueueslane=session:agent:main:<same-key>while the relaunched gateway logsresumed interrupted main sessionfor the same key.User Impact
After a gateway crash mid-turn, embedded fallback now always runs on a fresh
gateway-fallback-*session (for both timeout and closed transport failures, with afallbackReasonrecorded in result metadata), so it can never collide with gateway-side session recovery. Gateway recovery of the original session is unaffected.Evidence
resolveGatewayAgentEmbeddedFallbackReasonunifies both fallback triggers;GatewayTransportErrorKindis exactly"closed" | "timeout"(src/gateway/call.ts:120, constructed only atcall.ts:846/:859), so the pair is exhaustive — no transport failure loses fallback.src/commands/agent-via-gateway.test.ts). Focused suite: 74/74 pass.