Skip to content

The agent that grows with you

fix(agent): let an escalated overload clear stale terminal summary flags

kshitijk4poor5021e3633bac
diff --git a/agent/context_compressor.py b/agent/context_compressor.py
index 9aad076da7e..006690c2f4c 100644
--- a/agent/context_compressor.py
+++ b/agent/context_compressor.py
@@ -4179,6 +4179,11 @@ Write only the summary body. Do not include any preamble or prefix."""
self._consecutive_overload_aborts < _CONSECUTIVE_OVERLOAD_ABORT_ESCALATION
)
self._last_summary_overload_degraded = not self._last_summary_overload_failure
+ if self._last_summary_overload_degraded:
+ # The latest failure class decides: a stale network/empty/truncated/auth flag from
+ # an earlier failure (only a success clears those) must not keep aborting forever.
+ for flag, _class, _msg in _TERMINAL_SUMMARY_FAILURES:
+ setattr(self, flag, False)
logger.warning(
"Failed to generate context summary: %s. Further summary attempts paused for %d seconds.", e,
_transient_cooldown,
diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.py
index dbf438601d5..db2f94c49e7 100644
--- a/tests/agent/test_context_compressor.py
+++ b/tests/agent/test_context_compressor.py
@@ -1064,6 +1064,9 @@ class TestSustainedOverloadEscalation:
def test_first_overloads_still_abort_then_third_commits_fallback(self):
c = self._compressor(abort_on_summary_failure=False)
+ # A stale terminal flag from one earlier network failure (only a success clears it) must
+ # not pin the long-lived compressor in abort mode: the latest failure class decides.
+ c._last_summary_network_failure = True
msgs = self._msgs(12)
with patch("agent.context_compressor.call_llm", side_effect=self._err()):
first = c.compress(msgs, current_tokens=999999, force=True)