fix(compression): add deterministic handoff for fallback compaction#26189
fix(compression): add deterministic handoff for fallback compaction#26189carltonawong wants to merge 1 commit into
Conversation
9e7833a to
84f1df8
Compare
|
Updated this branch on top of current
So this PR is intended to complement the new config flag: when callers choose the safest preservation mode, nothing is dropped; when they keep the default fallback behavior or need compaction to proceed under context pressure, the dropped window now leaves actionable, redacted context behind. Validated after rebasing: python -m pytest -o addopts='' tests/agent/test_context_compressor.py -qResult: |
84f1df8 to
759f544
Compare
|
Refreshed this branch on top of current The PR is still intentionally narrow: it only changes the summary-failure fallback path in Validated after rebasing: python -m pytest -o addopts='' tests/agent/test_context_compressor.py -qResult: Would appreciate a maintainer review when someone has bandwidth. I think this is complementary to the existing compression safety work because it covers the case where Hermes proceeds with compaction after summary generation fails. |
Summary
Adds a deterministic pre-drop handoff for the summary-failure fallback path in
ContextCompressor.When the LLM summary cannot be generated but Hermes still compacts a middle window, the fallback summary now includes bounded, redacted source context from the exact removed turns instead of only a generic “summary unavailable” marker.
Problem
Failed summary compression currently preserves the fact that context was lost, but not the actionable state needed to continue safely.
That matters in long-running gateway sessions: durable memory and recent tail context may still exist, but the removed middle window can contain the active workflow trigger, tool state, file/path references, or the last concrete user ask. A generic fallback marker tells the next model that something was dropped, but gives it little evidence for correct continuation.
Skipping a failed compression attempt is safest when the full message list can still be retained. This patch handles the lossy fallback case where Hermes is already compacting a middle window and needs a non-LLM continuity receipt from the exact dropped span.
Changes
agent/context_compressor.pytests/agent/test_context_compressor.pyRelationship to existing compression fixes
Related to #25585 and the fallback-marker/context-loss reports such as #16670.
This is complementary to PRs like #26051 / #25588 that preserve the original message list when failed compression can be skipped safely. That is the preferred behavior when the full context can still be retained.
This PR covers the remaining hard fallback case: if Hermes is going to replace a middle window anyway, the replacement should contain deterministic source evidence from the dropped span, not just a generic marker.
Invariant this moves toward:
Validation
Type of Change
Checklist
Code
Documentation & Housekeeping
cli-config.yaml.exampleN/A — no config keys changed