fix(agent): pass memory-provider on_pre_compress() insights to compression summary - #43567
fix(agent): pass memory-provider on_pre_compress() insights to compression summary#43567liuhao1024 wants to merge 2 commits into
Conversation
…ssion summary The MemoryManager.on_pre_compress() method returns provider-extracted insights that should survive context compaction, but the caller in conversation_compression.py discarded the return value. This meant memory providers' pre-compression observations were silently lost when the compressor summarized old turns. Now the return value is captured, stored on the compressor instance, and injected into the summarizer prompt as a "MEMORY PROVIDER INSIGHTS" section so the compressor preserves them in the summary. Fixes NousResearch#43558
|
Duplicate of #7195 (open) — same fix, same files ( |
|
We hit this independently while building an out-of-tree One thing that may help unblock this: there appear to be two compression paths that behave differently for the same hook.
If both descriptions are accurate, the hook's return value is honored on one path and dropped on the other. That inconsistency — rather than a single missing wire — may be the underlying issue, and reconciling the two paths so the hook behaves the same regardless of which compression entry point runs seems like the thing to settle. Happy to share a minimal repro if it helps. |
|
This PR (#43567) is indeed addressing the same issue as #7195, but the implementations are different in technical approach. Here's a detailed comparison: File Coverage
Key Implementation Difference#7195 (Tranquil-Flow):
#43567 (this PR):
Test Coverage Comparison#7195: 3 static assertions in a new test file (checks presence in source) #43567: 7 comprehensive unit tests covering:
Recommendation#7195 is preferred for:
#43567 has merit for:
Action SuggestedSince #7195 is already open and addressing the same issue with a simpler approach, I recommend closing #43567 as a duplicate. The comprehensive tests from this PR could potentially be added to #7195 if the maintainer agrees. Reference: alt-glitch comment already flagged this overlap. |
What does this PR do?
Fixes
MemoryProvider.on_pre_compress()return value being silently discarded inconversation_compression.py. Memory providers' pre-compression insights are now passed to the summarizer prompt so they survive context compaction.Related Issue
Fixes #43558
Type of Change
Changes Made
agent/conversation_compression.py: Capture return value ofon_pre_compress()and store on compressor instance instead of discarding itagent/context_compressor.py: Addprovider_insightsparameter to_generate_summary(), inject as "MEMORY PROVIDER INSIGHTS" section in the summarizer prompt; capture and clear insights at the start ofcompress()to prevent stale data on re-entry; propagate insights through retry pathstests/agent/test_context_compressor.py: 7 new tests covering insights injection, empty/whitespace handling, iterative update, cleanup after compress, parameter forwarding, and retry survivalHow to Test
on_pre_compress()pytest tests/agent/test_context_compressor.py::TestProviderInsightsInCompression -v— all 7 tests should passpytest tests/agent/test_context_compressor.py -v— all 101 tests should pass (no regressions)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/agent/test_context_compressor.py -vand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
agent/conversation_compression.py:compress_context()(caller),agent/context_compressor.py:_generate_summary()(receiver),agent/memory_manager.py:on_pre_compress()(interface)focus_topicparameter follows the same injection pattern into the summarizer prompt