Skip to content

fix(compression): preserve network/auth abort flags across cooldown re-entry (#29559) - #52056

Closed
srojk34 wants to merge 1 commit into
NousResearch:mainfrom
srojk34:fix/compression-cooldown-reentry-data-loss
Closed

fix(compression): preserve network/auth abort flags across cooldown re-entry (#29559)#52056
srojk34 wants to merge 1 commit into
NousResearch:mainfrom
srojk34:fix/compression-cooldown-reentry-data-loss

Conversation

@srojk34

@srojk34 srojk34 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Repro scenario

  1. Network blip causes ConnectionError during auto-compress → first compress() correctly aborts (PR fix(compression): abort + preserve context on transient network summary failure (#29559, #25585) #51881) ✅
  2. User sends another message (adding tokens) → second compress() triggers within 30s cooldown
  3. compress() resets _last_summary_network_failure = False_generate_summary() hits cooldown guard, returns None without re-setting flag → abort guard sees Falsemiddle window dropped

Fix

Remove the eager _last_summary_auth_failure = False / _last_summary_network_failure = False reset at the top of compress(). The flags are already cleared on success, and persisting them during cooldown is safe and correct.

Test plan

  • TestCooldownReentryAbort::test_network_failure_cooldown_reentry_still_aborts — ConnectionError → first compress aborts → second compress during cooldown also aborts (not fallback)
  • TestCooldownReentryAbort::test_auth_failure_cooldown_reentry_still_aborts — same for 401 auth failures
  • All 122 existing test_context_compressor.py tests pass (zero regression)
$ pytest tests/agent/test_context_compressor.py -q
122 passed in 7.97s

…e-entry (NousResearch#29559)

compress() unconditionally reset _last_summary_network_failure and
_last_summary_auth_failure at the top of every call.  When a second
auto-compress fired during the 30s failure cooldown,
_generate_summary() returned None from the cooldown early-return
without re-asserting these flags — so the abort guard saw False and
fell through to the destructive static-fallback path, dropping the
middle context window.  This re-introduced the exact data-loss
scenario that PR NousResearch#51881 / issue NousResearch#29559 fixed.

Both flags are already cleared on success (_generate_summary lines
1697-1698), so the eager reset was redundant.  Remove it so the
flags persist during cooldown and the abort guard fires correctly
on re-entry.

Adds two regression tests (network + auth) that trigger compress()
twice — once to fail and once during cooldown — asserting the second
call also returns messages unchanged with _last_compress_aborted=True.
@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state labels Jun 24, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused fix. I verified the premise against current main and did not find blocking problems.

Current main still resets _last_summary_auth_failure / _last_summary_network_failure at agent/context_compressor.py:2402, while _generate_summary() returns during cooldown at agent/context_compressor.py:1476 without reasserting them. The abort guard at agent/context_compressor.py:2530 then misses the prior network/auth failure and falls through to the fallback path. I also reproduced that locally with .venv/bin/python: first ConnectionError compression preserved all 12 messages, second cooldown re-entry dropped to 6 messages with _last_summary_fallback_used=True.

The PR’s shape matches the bug class: it removes the eager resets and adds network plus auth regression tests for second-call cooldown re-entry. It also preserves the success path, where _generate_summary() already clears both flags at agent/context_compressor.py:1697.

No design-fit issues found: no new tools, env vars, schema surface, or cache-breaking prompt changes. Salvageability looks high; this should be mostly mechanical to cherry-pick.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jun 29, 2026
kshitijk4poor pushed a commit that referenced this pull request Jul 1, 2026
…e-entry (#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss #29559/#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from #52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Landed on main in commit 82ac7e1 (authorship preserved) via batch salvage #56197. The eager flag-reset removal now correctly preserves the abort across cooldown re-entry — verified with a mutation-checked regression test. Thanks @srojk34!

hashbender added a commit to hashbender/hermes-agent that referenced this pull request Jul 1, 2026
…rt flags, system-head summary role (NousResearch#51225 NousResearch#52056 NousResearch#52167) (#208)

Co-authored-by: qbit-mirror-bot <qbit-mirror-bot@users.noreply.github.com>
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
…e-entry (NousResearch#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss NousResearch#29559/NousResearch#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from NousResearch#52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
caozuohua pushed a commit to caozuohua/hermes-agent that referenced this pull request Jul 2, 2026
…e-entry (NousResearch#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss NousResearch#29559/NousResearch#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from NousResearch#52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
(cherry picked from commit 82ac7e1)
Jasper6439 pushed a commit to Jasper6439/hermes-agent that referenced this pull request Jul 5, 2026
…e-entry (NousResearch#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss NousResearch#29559/NousResearch#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from NousResearch#52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
habarmc1223-sudo pushed a commit to habarmc1223-sudo/hermes-agent-fluxmem that referenced this pull request Jul 8, 2026
…e-entry (NousResearch#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss NousResearch#29559/NousResearch#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from NousResearch#52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
santhreal pushed a commit to santhreal/hermes-agent that referenced this pull request Jul 13, 2026
…e-entry (NousResearch#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss NousResearch#29559/NousResearch#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from NousResearch#52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
Gravezzz pushed a commit to Gravezzz/hermes-agent that referenced this pull request Jul 21, 2026
…e-entry (NousResearch#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss NousResearch#29559/NousResearch#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from NousResearch#52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
leewenjie pushed a commit to leewenjie/hermes-agent that referenced this pull request Aug 7, 2026
…e-entry (NousResearch#29559)

compress() eagerly reset _last_summary_auth_failure and
_last_summary_network_failure at the top of every call. On a second
compress() during the failure cooldown, _generate_summary() returns None from
the cooldown early-return WITHOUT re-asserting those flags, so the abort guard
saw False and fell through to the destructive static-fallback that drops the
middle window — the data-loss NousResearch#29559/NousResearch#25585 describe. Stop resetting them
eagerly; a successful summary already clears both, so letting them persist
across calls is safe and keeps the cooldown abort protection intact.

Salvaged from NousResearch#52056.

Co-authored-by: srojk34 <286497132+srojk34@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint P1 High — major feature broken, no workaround sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform 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.

4 participants