fix(memory): forward on_pre_compress return value to compress() as pr… - #29598
fix(memory): forward on_pre_compress return value to compress() as pr…#29598buptwz wants to merge 1 commit into
Conversation
…ovider_context The return value of MemoryProvider.on_pre_compress() was silently discarded in conversation_compression.py — it was never passed to ContextCompressor.compress(), so memory providers had no way to guide the summarisation LLM on which facts to preserve. Changes: - conversation_compression.py: capture on_pre_compress() return value and forward it as provider_context= kwarg to compress() - context_compressor.py: add provider_context param to compress() and _generate_summary(); inject as MEMORY PROVIDER CONTEXT block in the LLM summarisation prompt when non-empty - holographic plugin: add reference on_pre_compress() returning top-trust stored facts as compression hints - tests: 10 new tests covering the full chain with mutation-verified coverage (breaking the chain causes tests to fail) Fixes NousResearch#23367 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Thanks for tracing the return value through the memory-provider and compression layers. The core premise remains valid on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
|
This fix has landed on main via PR #67938 (salvaged from PR #64342 by @GottZ, which consolidated the on_pre_compress return-value forwarding with sanitization, engine-signature compatibility, and lock hardening). Your PR correctly identified the same root cause — the provider's return value being silently discarded before compression. The merged implementation supersedes this one, so closing it. First-submitter credit goes to @jairodriguez (#11236, Apr 16); thank you for the independent confirmation and fix. |
Problem
Fixes #23367.
MemoryProvider.on_pre_compress()lets external memory backends return a hint string telling the summarisation LLM which facts to preserveduring compression. The return value was silently discarded — every provider implementing this hook was being ignored.
Root Cause
conversation_compression.pycalledon_pre_compress()but threw away the return value.ContextCompressor.compress()had noprovider_contextparameter, so the hint had nowhere to go even if captured.Solution
conversation_compression.py: captureon_pre_compress()return value, forward tocompress()context_compressor.py: addprovider_contextparam tocompress()/_generate_summary(); inject asMEMORY PROVIDER CONTEXTblockin the LLM summarisation prompt
holographicplugin: add referenceon_pre_compress()returning top-trust stored factsTests
10 new tests, all pass. Mutation-verified.
tests/agent/test_compress_focus.py(4):provider_contextinjected into LLM prompt, empty string skipped, coexists withfocus_topic,forwarded through
compress()tests/agent/test_memory_provider.py(3): hint text passes throughMemoryManager, empty and whitespace-only returns handled correctlytests/run_agent/test_compression_boundary_hook.py(3): end-to-end integration — hint flows fromon_pre_compress()intocompress(provider_context=...)via real `AIAgentTested on: Linux (Ubuntu 24.04, Python 3.13)