Repository navigation
feat(chat): context overflow protection — auto-summarize when approaching model context limit (#9043) - #9161
Merged
Merged
Conversation
Implements core classes for context window overflow protection: - SessionTokenTracker: tracks cumulative token usage per session in Redis - ConversationSummarizer: uses LLM to create intelligent summaries - ContextOverflowProtection: orchestrates detection, warning, and auto-summarization Builds on #8990 (token tracking) and #3770 (compression service). Next: integration with chat endpoints, tests, and LLC agent support. Co-Authored-By: Paperclip <noreply@paperclip.ing>
…9043) Tests cover: - SessionTokenTracker: token accumulation, reset, Redis failures - ConversationSummarizer: LLM summarization, empty messages, fallback - ContextOverflowProtection: warning triggers, auto-compress, mode handling All test cases verify acceptance criteria from #9043. Co-Authored-By: Paperclip <noreply@paperclip.ing>
Integration helpers for easy adoption in chat endpoints: - get_overflow_protection(): singleton access - handle_message_completion(): main integration point after LLM responses - create_summary_message(): format summary for injection - Environment-based configuration via AUTOBOT_CONTEXT_OVERFLOW_MODE Usage pattern documented in docstrings. Co-Authored-By: Paperclip <noreply@paperclip.ing>
Complete integration documentation with: - Quick start guide for chat endpoints - LLC agent heartbeat loop example - API reference for all integration functions - Testing instructions - Acceptance criteria mapping Provides clear pattern for adoption without tight coupling. Co-Authored-By: Paperclip <noreply@paperclip.ing>
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
Owner
Author
CodeReviewer AssessmentCI Status: ✅ GREEN
Code Quality: ✅ GOOD
Review Quality Checklist:
Verdict: ✅ Ready to merge Merging to Dev_new_gui. Reviewed and merged by CodeReviewer agent |
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
Implements automatic context window overflow protection for long conversations (#9043). System tracks cumulative token usage and auto-summarizes when approaching model limits.
Implementation
Core Module (
autobot-backend/chat_history/context_overflow.py):SessionTokenTracker: Redis-backed token usage tracking with TTLConversationSummarizer: LLM-powered intelligent summarizationContextOverflowProtection: Orchestrates detection and protectionIntegration Layer (
overflow_integration.py):handle_message_completion(): Main integration point for chat endpointscreate_summary_message(): Format summaries for injectionAUTOBOT_CONTEXT_OVERFLOW_MODE)Test Coverage:
Protection Modes
Integration Pattern
Follow-up Work
Remaining tasks delegated to child issues:
Test Plan
Related Issues
🤖 Generated with Claude Code