Skip to content

The agent that grows with you

fix(agent): label the escalated overload commit summary_overload_degraded

kshitijk4poor818faaf16d70
diff --git a/agent/context_compressor.py b/agent/context_compressor.py
index 006690c2f4c..3560c005dd0 100644
--- a/agent/context_compressor.py
+++ b/agent/context_compressor.py
@@ -5208,10 +5208,9 @@ Write only the summary body. Do not include any preamble or prefix."""
self._last_summary_fallback_used = True
telemetry["fallback_used"] = True
# Feasibility skip is deliberate, not aux-model breakage — keep the telemetry class distinct.
- telemetry["failure_class"] = telemetry.get("failure_class") or (
- "feasibility_skip" if feasibility_skip
- else "summary_overload_degraded" if getattr(self, "_last_summary_overload_degraded", False)
- else "summary_generation_failed"
+ # An escalated overload outranks the aux->main retry's earlier aux_model_fallback label.
+ telemetry["failure_class"] = "summary_overload_degraded" if self._last_summary_overload_degraded else (
+ telemetry.get("failure_class") or ("feasibility_skip" if feasibility_skip else "summary_generation_failed")
)
return self._build_static_fallback_summary(
turns_to_summarize,
diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.py
index db2f94c49e7..a5cbb5f0e32 100644
--- a/tests/agent/test_context_compressor.py
+++ b/tests/agent/test_context_compressor.py
@@ -1113,12 +1113,12 @@ class TestSustainedOverloadEscalation:
with patch("agent.context_compressor.call_llm", side_effect=self._err()):
third = second.compress(msgs, current_tokens=999999, force=True)
# Third consecutive abort IN THE SESSION escalates even though this object saw one.
- # (A fresh object's first overload may burn the aux→main one-shot retry first, which
- # claims telemetry failure_class=aux_model_fallback; the escalation contract is the
- # committed fallback + settled budget, not which telemetry label won the race.)
+ # A fresh object's first overload burns the aux→main one-shot retry, which labels the
+ # attempt aux_model_fallback first; the escalated commit must still say what happened.
assert third != msgs
assert second._last_summary_fallback_used is True
assert second._last_summary_overload_degraded is True
+ assert second._last_compression_telemetry["failure_class"] == "summary_overload_degraded"
# The committed degraded fallback settles the budget so recovery gets a fresh run
# (the boundary caller records the completed compaction, as compress_context does).
second.record_completed_compaction(used_fallback=True)