fix: wire on_pre_compress() into summary prompt and persist compaction summaries#11236
Open
jairodriguez wants to merge 1 commit into
Open
fix: wire on_pre_compress() into summary prompt and persist compaction summaries#11236jairodriguez wants to merge 1 commit into
jairodriguez wants to merge 1 commit into
Conversation
…n summaries to disk Bug: MemoryManager.on_pre_compress() was called in _compress_context() but its return value was discarded. External memory providers (ByteRover, etc.) would extract insights before context was lost, but those insights were never injected into the compaction summary prompt. Changes: - Capture on_pre_compress() return value and thread it through compress() -> _generate_summary() as provider_context parameter - Inject provider context into the LLM summary prompt so insights survive - Persist compaction summaries to ~/.hermes/sessions/compaction_summary_*.md for cross-session continuity and post-compaction recovery - Add context-recovery skill for detecting compaction and reconstructing lost context from persisted summaries + session history The persisted summaries are also available for the new context-recovery skill which detects compaction markers and reconstructs context from multiple sources. Tests: 40/40 context_compressor, 46/46 memory_provider, 1117/1122 agent tests pass (5 pre-existing failures unrelated to this change).
Collaborator
|
Likely duplicate of #7195 — both wire the on_pre_compress() return value into the compressor. This PR additionally adds disk persistence for compaction summaries. |
13 tasks
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.
Bug:
on_pre_compress()return value discarded + no summary persistenceProblem
When Hermes compacts context, two issues cause context loss:
on_pre_compress()return value ignored —MemoryManager.on_pre_compress()collects insights from external memory providers (ByteRover, etc.) before context is compressed, but_compress_context()inrun_agent.pycalls it without capturing the return value. Provider insights are gathered but never injected into the compaction summary.No summary disk persistence — The compaction summary is held in memory (
_previous_summary) for iterative updates within a session, but never written to disk. If the session restarts or crashes, the summary is lost entirely. There's no mechanism to recover context across sessions.Changes
run_agent.py:on_pre_compress()return value intoprovider_contextvariableprovider_contextthrough tocompress()→_generate_summary()~/.hermes/sessions/compaction_summary_{session_id}.mdagent/context_compressor.py:compress()accepts newprovider_contextparameter (backward-compatible, defaults to"")_generate_summary()accepts newprovider_contextparameterTesting
Impact