Fix conversation context loss between Telegram messages#6
Open
RichardAtCT wants to merge 1 commit intomainfrom
Open
Fix conversation context loss between Telegram messages#6RichardAtCT wants to merge 1 commit intomainfrom
RichardAtCT wants to merge 1 commit intomainfrom
Conversation
The bot was losing conversation context between messages because the session manager was incorrectly creating new sessions even when valid session IDs were provided. This happened when sessions weren't in the active cache (e.g., after bot restart). Key fixes: - Properly distinguish between resuming existing Claude sessions vs starting fresh - Load existing sessions from storage with is_new_session=False - Add comprehensive logging for session flow debugging - Use --resume flag correctly for continuing conversations - Handle both temporary and Claude-generated session IDs appropriately Verified with comprehensive test that confirms: ✅ New sessions start correctly without --resume ✅ Follow-up messages use --resume with session ID ✅ Sessions persist to storage properly ✅ Sessions resume correctly after simulated bot restart Fixes: #5 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <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
Fixes conversation context not being maintained between messages in the Telegram integration.
Problem
The Telegram bot was losing conversation context between messages, treating each message as a new conversation instead of continuing the existing session. This prevented follow-up questions and iterative development workflows.
Root Cause
The session manager was incorrectly creating new sessions even when valid session IDs were provided. This happened when sessions weren't found in the active cache (e.g., after bot restart or cache eviction), causing the system to treat existing Claude sessions as "new sessions."
Solution
Key Changes
is_new_session=FalseFiles Modified
src/claude/session.py- Fixedget_or_create_sessionlogicsrc/claude/facade.py- Added session debugging and validationsrc/claude/integration.py- Added resume command loggingsrc/claude/sdk_integration.py- Enhanced SDK session loggingTesting
Verified with comprehensive test that confirms:
--resume--resumewith session IDTest Plan
Closes #5
🤖 Generated with Claude Code