fix: preserve session on timeout instead of destroying it#163
Open
gabmfranco-ds wants to merge 2 commits intoRichardAtCT:mainfrom
Open
fix: preserve session on timeout instead of destroying it#163gabmfranco-ds wants to merge 2 commits intoRichardAtCT:mainfrom
gabmfranco-ds wants to merge 2 commits intoRichardAtCT:mainfrom
Conversation
Timeouts are transient — the Claude session is still valid on the CLI side. Previously, any error during resume (including timeout) would delete the session and start fresh, causing the bot to lose all conversation context. Now ClaudeTimeoutError is caught separately and the session is kept intact so auto-resume works on the next message. Also bumps default timeout from 300s to 1200s for long-running operations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Previously, any error during session resume (timeout, process crash,
connection issue) would destroy the session and start fresh. Now the
session is only destroyed when the error message explicitly says the
session is gone ("session not found", "invalid session", etc.).
All other errors preserve the session and touch last_used so
auto-resume works on the next user message.
Also updates .env CLAUDE_TIMEOUT_SECONDS from 600 to 1200 (the
constants.py default is overridden by the env var).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ClaudeTimeoutErrorseparately from other resume errors. Timeouts are transient — the Claude session is still valid on the CLI side. The session is preserved so auto-resume works on the next message.Root cause
In
facade.py, theexcept Exceptionblock (line 92) caught all errors during session resume — including timeouts — and ran the "stale session" recovery path: delete session → create new → retry without history. ButClaudeTimeoutError ≠ session expired. The session is likely still alive on Claude's side; it just took too long to respond.Changes
src/claude/facade.pyClaudeTimeoutErrorbefore the genericExceptionhandler; preserve session and touchlast_usedto prevent expirationsrc/utils/constants.pyDEFAULT_CLAUDE_TIMEOUT_SECONDS: 300 → 1200Test plan
🤖 Generated with Claude Code