Skip to content

fix(compression): pass continuity advisory into compressor input - #21118

Closed
stefan-mcf wants to merge 1 commit into
NousResearch:mainfrom
stefan-mcf:fix/compression-continuity-advisory
Closed

fix(compression): pass continuity advisory into compressor input#21118
stefan-mcf wants to merge 1 commit into
NousResearch:mainfrom
stefan-mcf:fix/compression-continuity-advisory

Conversation

@stefan-mcf

Copy link
Copy Markdown

Summary

  • pass provider-supplied pre-compression advisory text into the compressor input without mutating the live transcript
  • log advisory injection and advisory-hook failures for observability
  • add regression tests covering advisory passthrough and non-fatal failure handling

Why

This is a separate Hermes-side compression continuity improvement. Some memory/context providers can supply advisory continuity text before compression. Hermes should make that text available to the compressor input while keeping the live transcript unchanged and while treating provider hook failures as non-fatal.

This PR is intentionally separate from delegation/subagent truncation hardening so each change has a single root-cause story.

Test plan

  • python -m pytest tests/run_agent/test_compression_boundary_hook.py -q -k 'ContinuityAdvisory or compression_boundary'

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have labels May 7, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for identifying the unconsumed on_pre_compress() return contract: current main documents that provider text belongs in the compression summary (agent/memory_manager.py:883-900), while the compression path currently discards it (agent/conversation_compression.py:631-639).

Problems

  • The proposed appended role="user" advisory does not reliably reach the summary input. The real compressor preserves its tail and anchors the last user message (agent/context_compressor.py:2670-2772), then passes only messages[compress_start:compress_end] to _generate_summary() (agent/context_compressor.py:2885, 2933-2935). The appended advisory is consequently protected as tail context rather than summarized.
  • The new tests use a mock compressor, so they cannot detect that tail-selection behavior.
  • Current run_agent.py:5608-5621 is only a forwarder; the live implementation is now agent/conversation_compression.py.

Suggested changes

  • Port the change to agent/conversation_compression.py and pass the advisory through a summary-specific path rather than a synthetic transcript message.
  • Add an integration-level regression test against ContextCompressor proving the advisory reaches _generate_summary() while neither the advisory nor a synthetic user turn survives in the compacted transcript.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/compression Context compression and continuation sessions labels Jul 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

This fix has landed on main via PR #67938 (salvaged from PR #64342 by @GottZ, which consolidated the on_pre_compress return-value forwarding with sanitization, engine-signature compatibility, and lock hardening).

Your PR correctly identified the same root cause — the provider's return value being silently discarded before compression. The merged implementation supersedes this one, so closing it. First-submitter credit goes to @jairodriguez (#11236, Apr 16); thank you for the independent confirmation and fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/compression Context compression and continuation sessions comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P3 Low — cosmetic, nice to have sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants