feat(memory): add long conversation mode with asymmetric compression#119
Open
basnijholt wants to merge 6 commits intomainfrom
Open
feat(memory): add long conversation mode with asymmetric compression#119basnijholt wants to merge 6 commits intomainfrom
basnijholt wants to merge 6 commits intomainfrom
Conversation
Implement chronological context with token budget enforcement for single long-running conversations. This mode maintains conversation history as segments and builds context by including recent turns up to the token budget. New features: - --long-conversation flag for memory proxy command - --context-budget, --compress-threshold, --raw-recent-tokens options - Segment and LongConversation data models - File-based persistence (markdown with YAML frontmatter) - Basic context building with token budget enforcement Phase 2+ (not yet implemented): - Asymmetric compression (user vs assistant) - Code block deduplication - Streaming support
…Phase 2) Implements intelligent compression that prioritizes assistant messages: - User messages: gentle 70% compression, preserve code blocks and quotes - Assistant messages: aggressive 20% compression to bullet points Adds integration tests covering the full transformation pipeline.
… (Phase 3) Add repetition detection that identifies near-duplicate code blocks and stores compact references with diffs instead of full content. - Extract fenced code blocks using regex - Detect similarity using difflib.SequenceMatcher (>85% threshold) - Store reference + unified diff when savings > 70% - Integrate deduplication into segment creation flow - Add 6 integration tests for repetition detection This saves tokens when users paste the same or similar code multiple times during a conversation.
8a1a0aa to
b72479b
Compare
…plication Add two integration tests to verify Phase 2 and Phase 3 features work together: - test_compression_and_deduplication_together: Verifies compression triggers mid-conversation and deduplication still works for repeated content - test_build_context_with_all_segment_states: Verifies build_context correctly handles raw, summarized, and reference segments in the same conversation
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
Adds a new
--long-conversationmode tomemory-proxythat maintains a single, continuous conversation with intelligent compression, optimized for 100-200k token context windows.Key insight: User input is precious and hard to summarize without loss. LLM output is verbose and derivable. Compress asymmetrically.
Features
Usage
agent-cli memory-proxy \ --long-conversation \ --context-budget 150000 \ --compress-threshold 0.8 \ --raw-recent-tokens 40000Implementation
Known limitations
len(text) // 4heuristicTest plan