fix(compressor): restore summary_model and reset fallen_back flag on session reset - #21783
Open
nftpoetrist wants to merge 1 commit into
Open
fix(compressor): restore summary_model and reset fallen_back flag on session reset#21783nftpoetrist wants to merge 1 commit into
nftpoetrist wants to merge 1 commit into
Conversation
Collaborator
…session reset _generate_summary() clears self.summary_model = "" when the configured aux model fails (404, 503, timeout) and falls back to the main model for the current compression call. This mutation is permanent for the lifetime of the ContextCompressor instance. Because the same instance is reused across /reset (run_agent.py calls on_session_reset() rather than recreating the compressor), every subsequent session silently uses the main model for compression instead of the configured aux model — even after a transient outage resolves. on_session_reset() already resets _summary_failure_cooldown_until to 0 so transient errors do not block a fresh session (fix NousResearch#15548). The same logic applies to summary_model: a per-session failure should not permanently degrade compression quality for subsequent sessions. Fix: store the originally configured value in _configured_summary_model at __init__ time, then restore summary_model from it in on_session_reset(). Also reset _summary_model_fallen_back to False so the one-shot fallback can fire again if the aux model fails in the new session. Fixes companion to NousResearch#15548
nftpoetrist
force-pushed
the
fix/compressor-summary-model-reset
branch
from
May 10, 2026 00:05
847ce2c to
0d4e00f
Compare
Contributor
|
Thanks for preserving this regression fix. The premise still holds on current main: Problems
Suggested changes
Automated hermes-sweeper review. |
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.
What does this PR do?
_generate_summary()clearsself.summary_model = ""when the configured auxiliary summary model fails (404, 503, timeout, etc.) and falls back to the main model for that compression call. This mutation is permanent for the lifetime of theContextCompressorinstance.reset_session_state()inrun_agent.pycallson_session_reset()on the same compressor instance on every/newand/reset— the compressor is never recreated.on_session_reset()already resets_summary_failure_cooldown_untilto 0 so transient errors do not block a fresh session (fix #15548 / salvage #19622). The same logic applies tosummary_model: a per-session fallback should not permanently degrade compression quality for every subsequent session.Without this fix: after one aux model failure in a long session, every
/resetsilently leavessummary_model = "". The configured model (e.g.aux_models.compressor.model = "gpt-4o-mini") is never used again — even if the aux model recovered — until the gateway is restarted.Root cause:
on_session_reset()did not includesummary_modelin its reset list, and_summary_model_fallen_backwas also left asTrue, preventing the one-shot fallback from firing again in the new session.Fix:
_configured_summary_modelat__init__time.self.summary_modelfrom it inon_session_reset()._summary_model_fallen_back = Falseso the fallback logic can fire once more if the model fails again in the new session.Symmetric with the
_summary_failure_cooldown_until = 0.0reset already present in the same method.Related Issue
Companion to #15548 (same lifecycle class —
on_session_reset()not resetting a compressor field).Type of Change
Changes Made
agent/context_compressor.py: store_configured_summary_modelat init (+1 line); restore inon_session_reset()(+2 lines)tests/agent/test_context_compressor.py: 3 new regression tests inTestOnSessionResetSummaryModel(+35 lines)How to Test
python3.11 -m pytest tests/agent/test_context_compressor.py::TestOnSessionResetSummaryModel -v --override-ini="addopts="Expected: 3 passed.
Manual reproduction:
aux_models.compressor.modelto a model that will fail (wrong name / offline)./reset.Checklist
Code
Documentation & Housekeeping