fix(agent): capture on_pre_compress return value and pass to compressor#22576
Open
hbtjm9000 wants to merge 2 commits into
Open
fix(agent): capture on_pre_compress return value and pass to compressor#22576hbtjm9000 wants to merge 2 commits into
hbtjm9000 wants to merge 2 commits into
Conversation
added 2 commits
May 9, 2026 07:56
Two-channel pattern: 1. Side effect: persist tagged insights (decisions, artifacts, blockers, config changes) to Honcho via create_conclusion() on a daemon thread. Survives compression; feeds future sessions through dialectic layer. 2. Return: structured summary string injected into compression LLM prompt. Activates automatically once upstream fixes discarded return value (GH NousResearch#7192). Scope: last 12 messages (6 turns) — current task cycle only. Honcho's per-turn dialectic already captures user-model facts; this targets operational facts the compression LLM needs. Tested: guard paths (no-session, empty-messages, cron_skipped), extraction + threading + create_conclusion call all verified.
MemoryProvider.on_pre_compress() return value was silently discarded at the call site in run_agent.py. This broke all memory plugins (Honcho, Holographic, Mem0, etc.) that rely on this hook to inject context into the compression summary. Changes: - run_agent.py: capture return value as pre_compress_context, pass memory_context=pre_compress_context to ContextCompressor.compress() - agent/context_compressor.py: add memory_context parameter to compress() and _generate_summary(); inject ## Memory Provider Context section into compression prompt when non-empty; update all 3 retry call sites to pass memory_context through - tests/agent/test_context_compressor.py: add TestOnPreCompressIntegration (3 tests) Fixes NousResearch#7192
Collaborator
This was referenced Jun 10, 2026
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.
What does this PR do?
Captures the return value of
MemoryProvider.on_pre_compress()and passes it through to the context compressor's summarization prompt. Previously, the return value was silently discarded — every memory plugin returning compression context was broken without any error.The fix threads
memory_contextthrough three layers:run_agent.py— capture return value aspre_compress_contextContextCompressor.compress()— acceptmemory_contextparameterContextCompressor._generate_summary()— inject into compression promptRelated Issue
Fixes #7192
Type of Change
🐛Bug fix (non-breaking change that fixes an issue)Changes Made
run_agent.py(+28 lines)on_pre_compress()return value aspre_compress_contextmemory_context=pre_compress_contexttoself._context_compressor.compress()agent/context_compressor.py(+36 lines)compress(): addmemory_context: str = ""parameter + docstring note_generate_summary(): addmemory_context: str = ""parameter## Memory Provider Contextsection when non-empty (using pre-defined variable to avoid Python 3.11 f-string backslash restriction)memory_contextthroughtests/agent/test_context_compressor.py(+83 lines)TestOnPreCompressIntegrationclass with 3 tests:test_compress_accepts_memory_context_kwargtest_generate_summary_injects_memory_context_into_prompttest_empty_memory_context_does_not_add_sectionHow to Test
All 75 existing tests continue to pass.
Checklist
fix(agent):Conventional Commitspytest tests/agent/test_context_compressor.py -qpasses