fix(compressor): reset cooldown and model-fallback flag on session reset (#16067) - #16152
Closed
briandevans wants to merge 1 commit into
Closed
Conversation
…set (NousResearch#16067) ContextCompressor.on_session_reset() was missing two attribute resets: 1. _summary_failure_cooldown_until — when compression summary fails (no aux provider, rate limit, transient error) the compressor enters a cooldown of up to 10 minutes before retrying. /new or /reset should clear this fully so the next session starts fresh. Without the reset, a failure in session A causes summarization to be silently skipped at the start of session B. 2. _summary_model_fallen_back — tracks whether the compressor has already tried and failed the primary summary model and switched to a fallback. Persisting this flag across sessions means session B always skips the primary model even though the failure was in session A. Both attributes are initialized to their clean values in __init__ but were omitted from on_session_reset, which is the /new and /reset path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Collaborator
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes cross-session leakage in the agent’s ContextCompressor by ensuring additional per-session summarization state is cleared when the user starts a new session (/new) or resets (/reset).
Changes:
- Reset
_summary_failure_cooldown_untilto0.0inContextCompressor.on_session_reset(). - Reset
_summary_model_fallen_backtoFalseinContextCompressor.on_session_reset(). - Add unit tests asserting both values are cleared by
on_session_reset().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
agent/context_compressor.py |
Clears summarization cooldown and fallback flag during session reset to prevent state leaking across sessions. |
tests/agent/test_context_engine.py |
Adds regression tests for session reset clearing cooldown and fallback flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+300
to
+301
| self._summary_failure_cooldown_until = 0.0 | ||
| self._summary_model_fallen_back = False |
| self._last_compression_savings_pct = 100.0 | ||
| self._ineffective_compression_count = 0 | ||
| self._summary_failure_cooldown_until = 0.0 | ||
| self._summary_model_fallen_back = False |
| """_summary_model_fallen_back must be False after reset. | ||
|
|
||
| If the summary model fell back in session A, the fallback flag must not | ||
| persist into session B — the primary model should be tried first again. |
Contributor
Author
CI baseline classificationThe
These failures reproduce on |
Contributor
Author
19 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.
Summary
self._summary_failure_cooldown_until = 0.0toon_session_reset()self._summary_model_fallen_back = Falsetoon_session_reset()The bug
ContextCompressor.on_session_reset()(called on/newand/reset) was missing two attribute resets:1.
_summary_failure_cooldown_until— when compression summary fails (no aux provider, rate limit, transient error), the compressor sets a cooldown of up to 10 minutes before retrying. This attribute was initialized to0.0in__init__but was never zeroed inon_session_reset(). Result: a compression failure in session A causes summarization to be silently skipped at the start of session B, with the log line"Skipping context summary during cooldown"as the only indication.2.
_summary_model_fallen_back— set toTruewhen the primary summary model fails and a fallback is selected. Also missing fromon_session_reset(). Result: session B always skips the primary model and goes straight to the fallback, even though the failure was in a different session entirely.Both attributes are set to their clean values in
__init__but the reset path was incomplete.Test plan
on_session_reset()call —_summary_failure_cooldown_untilremains~600sand_summary_model_fallen_backremainsTrueTestCompressorSessionReset::test_reset_clears_summary_failure_cooldownandtest_reset_clears_summary_model_fallen_backboth passTestCompressorSessionResettests passtests/agent/test_context_engine.pysuite unchangedRelated
🤖 Generated with Claude Code