Skip to content

fix(#300): Gemini exit code 42 self-heal for stale session after restart#357

Open
terrenceeLeung wants to merge 1 commit intozts212653:mainfrom
terrenceeLeung:fix/300-gemini-code42-session-selfheal
Open

fix(#300): Gemini exit code 42 self-heal for stale session after restart#357
terrenceeLeung wants to merge 1 commit intozts212653:mainfrom
terrenceeLeung:fix/300-gemini-code42-session-selfheal

Conversation

@terrenceeLeung
Copy link
Copy Markdown
Contributor

Summary

  • Classify Gemini CLI exit code 42 as missing_session (scoped to Gemini CLI: prefix) so the existing retry-without-session self-heal path triggers automatically
  • Document the empty-chain gap in invoke-single-cat.ts (blanket sessionId = undefined on empty chain breaks fresh threads; RC2 self-heal covers the restart case)
  • Add regression tests: classification assertion + end-to-end self-heal with sessionDeletes verification

Closes #300

Test plan

  • classifyResumeFailure('Gemini CLI: CLI 异常退出 (code: 42, signal: none)')missing_session
  • Non-Gemini code: 42 still classified as cli_exit (Gemini prefix scoping)
  • End-to-end: stale session → exit 42 → auto-retry without session → recovered
  • sessionManager.delete called before retry (persistent store cleanup)
  • No new test regressions (6 pre-existing failures unchanged)

Reviewed-by: 缅因猫/砚砚 (codex) — 2 rounds

🤖 Generated with Claude Code

…or self-heal retry

After system restart, in-memory SessionChainStore is cleared but Redis
retains stale sessionIds. When Gemini CLI resumes with a stale session,
it exits with code 42 ("no conversation found"). Previously this was
classified as generic cli_exit, bypassing the retry-without-session
self-heal path.

Changes:
- invoke-helpers.ts: add Gemini-scoped code 42 → missing_session rule
  before the generic cli_exit pattern
- invoke-single-cat.ts: document the empty-chain gap and RC2 self-heal
  strategy (blanket clear breaks fresh threads)
- invoke-single-cat.test.js: add classification assertion + end-to-end
  self-heal regression test with sessionDeletes verification

Reviewed-by: 缅因猫/砚砚 (codex)
[宪宪/Opus-46🐾]

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@terrenceeLeung terrenceeLeung deleted the fix/300-gemini-code42-session-selfheal branch April 3, 2026 07:40
@terrenceeLeung terrenceeLeung restored the fix/300-gemini-code42-session-selfheal branch April 3, 2026 08:19
@terrenceeLeung terrenceeLeung reopened this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: 系统重启后gemini的会话丢失

1 participant