fix(agent): flush pending memory retains before compaction boundary - #9
Open
liuhao1024 wants to merge 1 commit into
Open
fix(agent): flush pending memory retains before compaction boundary#9liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
Fixes NousResearch#64315. Context compression calls on_session_switch() without first flushing pending memory retains. When Hindsight's turn buffer is cleared, any pending retains dispatched after the last successful retain but before compaction fires are silently lost at the compaction boundary. The fix adds flush_pending(timeout=5.0) before the on_session_switch call, using the same try/except pattern as the existing memory manager calls. This ensures pending sync/prefetch work completes before the buffer is cleared. Adds a regression test that verifies flush_pending is called with timeout=5.0 before on_session_switch during compression.
liuhao1024
pushed a commit
that referenced
this pull request
Aug 15, 2026
- tests/agent/test_session_activity.py asserts against ACTIVITY_DESCRIPTION_MAX instead of the literal 120. - The session-stall WARNING log line names its config knob (agent.session_stall_timeout) so operators can find the setting. - hermes_state.py: collapse the triple blank line near line 191. - hermes_cli/status.py no longer imports the private hermes_cli.main._relative_time: the helper moved to a public home (hermes_cli.timefmt.relative_time); main._relative_time stays as a thin back-compat wrapper (sessions_cmd and external patchers keep working).
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?
Context compression triggers
on_session_switch()without first flushing pending memory retains. When Hindsight's turn buffer is cleared, anysync_all()dispatched after the last successful retain but before compaction fires are silently lost at the compaction boundary.The fix adds
flush_pending(timeout=5.0)before theon_session_switchcall, using the same try/except pattern as the existing memory manager calls. This ensures pending sync/prefetch work completes before the buffer is cleared.Related Issue
Fixes NousResearch#64315
Type of Change
Changes Made
agent/conversation_compression.py: Addflush_pending(timeout=5.0)call beforeon_session_switch()at compaction boundary (10 lines)tests/agent/test_compression_memory_flush.py: Add regression test that verifiesflush_pendingis called withtimeout=5.0beforeon_session_switchduring compressionHow to Test
Run the new regression test:
Observed result: test passes
Run existing compression tests to ensure no regression:
Observed result: all tests pass
(Optional) Manual verification with Hindsight provider:
memory.provider: hindsightinconfig.yamlcompression.threshold: 0.75(default)batch_retainentriesChecklist
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/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs