fix(agent): capture on_pre_compress return value and pass to compressor#7195
Open
Tranquil-Flow wants to merge 2 commits into
Open
fix(agent): capture on_pre_compress return value and pass to compressor#7195Tranquil-Flow wants to merge 2 commits into
Tranquil-Flow wants to merge 2 commits into
Conversation
0eca4a4 to
0c84992
Compare
0c84992 to
6b9ce96
Compare
The MemoryProvider.on_pre_compress() hook returns text that providers want preserved in the compression summary, but run_agent.py discarded the return value. Additionally, compress() and _generate_summary() had no mechanism to accept this context. - Capture on_pre_compress() return value in run_agent.py - Add memory_context parameter to compress() and _generate_summary() - Inject memory provider insights into summarization prompts Fixes all MemoryProvider plugins that return context from on_pre_compress() (currently silently broken for every plugin).
6b9ce96 to
9d2a83c
Compare
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— captures the return valuecompress()— accepts and forwards the new parameter_generate_summary()— injects a "MEMORY PROVIDER INSIGHTS" section into the summarization template when non-emptyRelated Issue
Fixes #7192
Type of Change
Changes Made
run_agent.pyline ~6078: Captureon_pre_compress()return value intopre_compress_context; pass tocompress()asmemory_context=agent/context_compressor.pycompress(): Addmemory_context: str = ""parameter; forward to_generate_summary()agent/context_compressor.py_generate_summary(): Addmemory_context: str = ""parameter; conditionally inject "MEMORY PROVIDER INSIGHTS" section into both the iterative-update and first-compaction promptsHow to Test
on_pre_compress()(e.g., Honcho, or a test stub)/compress)For code review only (no runtime test harness):
run_agent.pyline ~6078 — confirm return value is now capturedcompress()signature — confirmmemory_contextparameter exists_generate_summary()— confirm the "MEMORY PROVIDER INSIGHTS" section is injected conditionallyChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand 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/AScreenshots / Logs
N/A — see commit description and PR diff.