fix: preserve session on CLI timeout for auto-resume#24
Merged
PleasePrompto merged 1 commit intoPleasePrompto:mainfrom Mar 4, 2026
Merged
Conversation
Previously, when the CLI timed out mid-execution, the session ID was lost (especially for new sessions where the ResultEvent never arrived), the user received a generic error message, and the next message started a fresh session without context. Changes: - Capture session_id from SystemInitEvent during streaming so it survives a timeout kill before the final ResultEvent - Add __TIMEOUT__ marker in executor ResultEvent for reliable detection - Detect timeout in CLIService and set timed_out flag on CLIResponse - Add dedicated _handle_timeout() flow that persists the session for auto-resume on the next user message - Add timeout_error_text() with clear user-facing message explaining what happened and that the session is preserved Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2a8db49 to
c189909
Compare
2 tasks
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
ResultEventnever arrives), causing the next message to start a fresh session without contextsession_idfromSystemInitEventduring streaming so it survives a timeout kill_handle_timeout()flow that persists the session for auto-resumeChanges
__TIMEOUT__marker inResultEvent.resultfor reliable timeout detectionSystemInitEvent.session_idin_StreamCallbacks, detect timeout marker, settimed_outonCLIResponse, carry forwardinit_session_idin fallback path_handle_timeout()preserves session +timed_outchecks innormal()andnormal_streaming()timeout_error_text()with session-preserved messagingContext
This is complementary to the
TimeoutControllerin v0.11.0 which handles timeout prevention (warnings, activity-based extensions). This PR handles timeout recovery — what happens when the timeout actually fires despite the controller's best efforts.🤖 Generated with Claude Code