Implement session-based conversation history for PrettyGeminiBot#20
Merged
Implement session-based conversation history for PrettyGeminiBot#20
Conversation
- Add conversation_history array to store recent conversation rounds - Add PRETTY_GEMINI_BOT_HISTORY_LENGTH environment variable to control history length - Create new chat session for each message with recent history - Update clear() method to clear conversation history - Update .env.example with new environment variable Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
- Validate history_length to be non-negative using max(0, int(...)) - Fix history extraction to use correct indices based on history_before_length - Ensure new messages are appended correctly regardless of initial history size Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
- Define MESSAGES_PER_ROUND constant to make code more maintainable - Add validation to ensure both user and assistant messages exist before appending - Extract messages to variables for better readability and safety Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
- Remove redundant conditional check for empty list (slice notation handles it) - Use explicit None check instead of truthiness check for message validation - This ensures valid messages with falsy content are not incorrectly rejected Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
- Add validation to trim history at complete round boundaries - Handle edge cases where history might have incomplete rounds - Ensures conversation context integrity is maintained Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update dialogue creation logic for Pretty gemini bot
Implement session-based conversation history for PrettyGeminiBot
Jan 1, 2026
hiyouga
reviewed
Jan 1, 2026
- Remove unnecessary ValueError exception handling in history_length initialization - Remove unnecessary else block for incomplete conversation rounds check - Since conversation_history is always updated in pairs, incomplete rounds are impossible Co-authored-by: hiyouga <16256802+hiyouga@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR implements session-based conversation history management for PrettyGeminiBot, enabling the bot to maintain context across multiple user interactions while creating a new chat session for each message.
Key changes:
- Added configurable conversation history tracking via
PRETTY_GEMINI_BOT_HISTORY_LENGTHenvironment variable - Refactored from persistent chat session to session-per-message approach with history
- Implemented automatic history management with recent N rounds preserved
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| mini_ema/bot/pretty_gemini_bot.py | Adds conversation history array, implements session-based chat creation with history parameter, updates clear() to reset history, and adds logic to extract and store new messages |
| .env.example | Documents the new PRETTY_GEMINI_BOT_HISTORY_LENGTH environment variable with default value of 10 rounds |
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.
Modify Pretty Gemini Bot Conversation Logic ✅
Summary
Successfully implemented session-based conversation history management for PrettyGeminiBot:
PRETTY_GEMINI_BOT_HISTORY_LENGTHenvironment variable (default: 10 rounds)Implementation Details
The bot now maintains conversation context through:
conversation_historyarray that stores recent N rounds (configurable)MESSAGES_PER_ROUNDconstant for maintainabilityOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.