fix(agent): preserve memory-provider context during compression (salvage #64342) - #67938
Merged
Conversation
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).
teknium1
force-pushed
the
hermes/hermes-e7906cce
branch
from
July 20, 2026 08:29
d5873d4 to
5271ccb
Compare
Collaborator
This was referenced Jul 20, 2026
This was referenced Jul 20, 2026
Closed
This was referenced Aug 3, 2026
Skywind5487
added a commit
to Skywind5487/hermes-agent
that referenced
this pull request
Aug 17, 2026
Port the explicit plugin no-op session-boundary guard onto current upstream lifecycle seams and add a regression for the residual case not covered by semantic equality: cleanup-changed active context reported as noop must be adopted without rotating the session. Prior art: NousResearch#58495. Equal-copy no-progress handling remains upstream-owned by NousResearch#67938.
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.
Summary
Memory-provider context returned by
on_pre_compress()now survives compression: it is sanitized, bounded, and injected into the compression summary prompt instead of being silently discarded. Salvages PR #64342 by @GottZ (with a foundational commit by @Tranquil-Flow) onto current main with authorship preserved.Root cause:
compress_context()invokedagent._memory_manager.on_pre_compress(messages)but dropped its return value, despite theMemoryProvider/MemoryManagercontract stating the returned text should be included in the compression summary prompt.Changes
agent/conversation_compression.py: capture + sanitize theon_pre_compress()return and forward it to the engine; new_supported_compression_kwargs()inspects the engine signature so legacy plugin engines get only kwargs they accept (replaces the broadTypeErrorretry that could double-invoke a stateful compressor); lock lease refresher + release hardened across all failure paths (idempotent release, refresher-start/stop failures can't strand the lock); semantic no-op detection (equal-copy results skip boundary rewrite, in-place mutations restored).agent/context_compressor.py:_generate_summary()/compress()acceptmemory_context; injected into both initial and iterative summary prompts inside a JSON-string-escaped<memory-provider-context>frame (decode-as-data instruction, markers cannot escape the frame); survives aux→main summary retry.agent/context_engine.py:sanitize_memory_context()(strict redaction + 6K head/tail bound) and documented optionalforce/memory_contextparams on the ABC.agent/redact.py: opt-inredact_url_credentials=Truestrict mode — masks credential-named query params (incl. hyphen/percent-encoded aliases,;separators, fragments, relative and network-path refs) and URL userinfo. Default stays off so OAuth callback/magic-link URLs survive normal tool flows.Validation
scripts/run_tests.shSalvaged from #64342; duplicate cluster #11236, #21118, #22576, #29598 to be closed with credit (earliest: @jairodriguez, Apr 16).
Infographic