fix(compression): skip empty post-handoff summary windows (salvage #59526) - #70251
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewran on 25769d2 ℹ️ InfoDesktop E2E visual evidence · View test artifacts · View job1 visual diff. inline evidence upload failed. Failed to upload diff-665a0833239e-onboarding-overlay-diff.png with gh image (exit code 1): Error uploading /home/runner/work/_temp/e2e-evidence/diff-665a0833239e-onboarding-overlay-diff.png: step 0 (get upload token): uploadToken not found on repo page — do you have write access to NousResearch/hermes-agent? (or, if NousResearch enforces SAML SSO, authorize at https://github.com/orgs/NousResearch/sso) |
Contributor
|
CI triage: the blocking slice-4 failure appears unrelated to this compression diff. The same exact test and assertion ( |
teknium1
force-pushed
the
salv/59526-empty-window-guard
branch
from
July 23, 2026 20:06
cbdf9da to
25769d2
Compare
This was referenced Jul 24, 2026
5 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.
Skips the wasted aux-LLM summary call (and its noisy abort) when the newest handoff summary consumes the entire compressible window —
compress()now early-returns the transcript unchanged instead of dispatching_generate_summaryon empty input.Salvages PR #59526 by @WOLIKIMCHENG — cherry-picked onto current main with authorship preserved (
fix(compression): skip empty post-handoff summary windows, including the regression test). @ms-alan's #59737 independently identified the same bug and the same correct early-return site — credit to both; #59737 was opened 7h later without a test, so #59526 is the salvage vehicle.Fixes the #59496 shape.
The bug (verified on main @ c2c2449)
After the post-handoff slice recompute (
turns_to_summarize = pre_summary_turns + messages[summary_idx+1:compress_end], ~L4490-4503), an emptyturns_to_summarizestill reached_generate_summary(...)unconditionally (~L4548). Post-#69297 a standalone handoff strips toNonein_window_row, so a window containing only the handoff row genuinely produces an empty summarizer input — burning an aux LLM call that aborts noisily for zero benefit, every turn the shape recurs.Not covered by the existing guards: the
compress_start >= compress_endguard (#40803, ~L4396) fires at an earlier, different site; the semantic no-op check inconversation_compression.pyruns after the wasted call.Adaptations from the original diff (main moved under it)
_record_ineffective_compression_verdict()instead of the PR's stale bare_ineffective_compression_count += 1— fix(compression): persist anti-thrash state across process restarts #69872 made the anti-thrash counter durable, and all strike/clear sites must write through the helper so the persisted copy stays in sync.compress_start >= compress_endguard's behavior exactly — the empty-window shape cannot shrink, so without a strikeshould_compress()keeps saying yes and every subsequent turn re-fires the same no-op loop. That is the precise failure [Bug]: Infinite Context Compaction Loop (messages=N->N) on low context_length / limit configurations #40803's guard exists to stop; this guard inherits the same contract.chunk_counttelemetry, well below the top-of-function per-call state reset — so the fix(compression): reset in-place compaction state on every abort path #69853_last_compression_attempt_*per-attempt abort-state semantics are untouched (verified bytests/run_agent/test_compression_abort_state_reset.py, all green)._previous_summaryrehydration is deliberately kept (not rolled back as the summary-abort path does for fix(agent): decay protected summaries after restart #57835): the rehydrated summary came from a handoff genuinely present in the transcript, which is returned unchanged.failure_class = "empty_post_handoff_window"distinguishes this skip fromno_compressible_window/insufficient_messagesin the attempt log._generate_summarybeing called and a normal compaction succeeding). The fixture was reshaped so the standalone handoff is the only window row, and the test now also pins thefailure_classand the strike-through-helper behavior. Kept in the contributor's commit alongside their guard.Note: the skip returns the input transcript per the standard caller contract for no-op skips (callers gate post-compaction bookkeeping on
result is not input; Phase-1 tool-result pruning may still return a pruned copy, exactly as on the sibling guard paths — the contract is unchanged by this PR).Validation
origin/mainsource_generate_summarycalled once on empty window) — bug reproducedtests/agent/test_context_compressor*.py+tests/run_agent/test_compression_abort_state_reset.pytests/agent/test_compress*.py+test_context_compressor*.py+ abort-state suite (rebased tip)ruff checkon changed filesast.parseafter conflict resolutionAttribution
fix(compression): skip empty post-handoff summary windows— author @WOLIKIMCHENG (kinsonnee@gmail.com), cherry-picked from fix(compression): skip empty post-handoff summary windows #59526 with authorship preserved; window-guard hunk surgically reapplied at its current home (the region was rewritten by fix(compression): dedupe persisted compaction handoffs #69297/fix(compression): decay head protection after restart when a persisted summary exists #69342/fix(compression): persist anti-thrash state across process restarts #69872 since the PR branched).scripts/add_contributor.py(contributors/emails/kinsonnee@gmail.com).Infographic