fix(compression): abort + preserve context on transient network summary failure (#29559, #25585) - #51881
Merged
kshitijk4poor merged 1 commit intoJun 24, 2026
Conversation
Contributor
🔎 Lint report:
|
…ry failure (#29559, #25585) When context compaction's summary generation fails, the compressor's default path (abort_on_summary_failure=False) drops the middle window and inserts a static 'summary unavailable' marker — destroying the compacted turns. #29559 reported the field impact: a Connection error at the compaction moment dropped 124->15 messages (110 lost) for a long browser-automation task; #25585 is the same failure mode (failed summary commits a destructive compaction anyway). compress() already has an EXCEPTION to the historical drop default: auth failures (401/403) ALWAYS abort and preserve the session, because rotating into a placeholder-summary child on a broken credential strands the user. A transient network/connection error is the same situation in reverse: it WILL recover, and retrying then is strictly better than discarding context for a momentary blip. Extend the always-abort carve-out to terminal connection/network failures: - new _last_summary_network_failure flag, set in _generate_summary's terminal failure branch when _is_connection_error(e) (reached only after any main-model fallback is exhausted), reset alongside the auth flag; - compress() aborts when it's set (returns messages unchanged, _last_compress_aborted=True), independent of abort_on_summary_failure; - a network-specific operator warning (distinct from the auth + config-flag messages). Scoped to connection errors only: a generic 500/400 still takes the historical fallback-drop path (test_non_auth_failure_still_uses_fallback_path stays green). Tests: network-failure detection + abort-despite-flag-false, both mutation-checked (removing the flag-set fails detection; removing the carve-out fails the abort).
kshitijk4poor
force-pushed
the
fix/29559-compression-abort-on-network-failure
branch
from
June 24, 2026 13:01
05f3082 to
ac822e4
Compare
kshitijk4poor
enabled auto-merge
June 24, 2026 13:02
Ari4ka
approved these changes
Jun 24, 2026
3 tasks
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…pression-abort-on-network-failure fix(compression): abort + preserve context on transient network summary failure (NousResearch#29559, NousResearch#25585)
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…pression-abort-on-network-failure fix(compression): abort + preserve context on transient network summary failure (NousResearch#29559, NousResearch#25585)
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…pression-abort-on-network-failure fix(compression): abort + preserve context on transient network summary failure (NousResearch#29559, NousResearch#25585)
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…pression-abort-on-network-failure fix(compression): abort + preserve context on transient network summary failure (NousResearch#29559, NousResearch#25585)
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…pression-abort-on-network-failure fix(compression): abort + preserve context on transient network summary failure (NousResearch#29559, NousResearch#25585)
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.
Summary
Closes #29559 and #25585 (same root cause / same code path) — context compaction destroys the compacted turns when summary generation fails on a transient network error.
When the auxiliary summary call fails and
compression.abort_on_summary_failureis at its default (False),compress()falls through to the fallback path: it inserts a static "summary unavailable" marker and drops the middle window anyway.Connection error.at the compaction moment dropped 124 → 15 messages (110 lost) mid-task — catastrophic for long browser-automation / multi-step work; the agent "forgets" and redoes/misassumes.Verified still live on current
mainby default (the abort-and-keep path exists but is opt-in).Fix
compress()already carves out an always-abort exception for auth failures (401/403) regardless of the config flag — rotating into a placeholder-summary child on a broken credential strands the user. A transient network/connection error is the same logic in reverse: it will recover, so retrying then is strictly better than discarding context for a momentary blip.Extend that carve-out to terminal connection/network failures:
_last_summary_network_failureflag, set in_generate_summary's terminal failure branch when_is_connection_error(e)(reached only after any main-model fallback is exhausted), reset alongside the auth flag;compress()aborts when it's set — returns messages unchanged,_last_compress_aborted=True— independent ofabort_on_summary_failure;Scoped to connection errors only: a generic 400/500 still takes the historical fallback-drop path (
test_non_auth_failure_still_uses_fallback_pathstays green). This mirrors an existing house pattern (the auth carve-out) rather than flipping the global default.Tests
tests/agent/test_context_compressor.py:test_generate_summary_flags_network_failure— aConnectionErrorflags_last_summary_network_failure(not auth);test_compress_aborts_on_network_failure_despite_flag_false— with the default flag off, a connection error aborts (messages unchanged,_last_compress_aborted=True, no fallback-drop).Both mutation-checked (removing the flag-set fails detection; removing the carve-out fails the abort). Full
test_context_compressor.pysuite: 120 passed.Attribution
Thanks to @MattChen1981 (#29559) for the field report + repro and @franksong2702 (#25585) for the precise failure-mode writeup and proposed approach.
Fixes #29559
Fixes #25585