Skip to content

The agent that grows with you

fix(compression): keep transport timeouts terminal; reclassify only the Codex stall

kshitijk4poor3a1a45dbf170
diff --git a/agent/context_compressor.py b/agent/context_compressor.py
index 5836a869afc..ac0bbac8ce3 100644
--- a/agent/context_compressor.py
+++ b/agent/context_compressor.py
@@ -744,22 +744,20 @@ def _classify_summary_failure(e: Exception) -> _SummaryFailureKind:
"""
status = _exc_status_code(e)
err = str(e).lower()
- timeout = (isinstance(e, TimeoutError)
- or status in {408, 429, 502, 504}
- or "timeout" in err or "timed out" in err or "stalled" in err)
+ # The Codex aux stream guard raises TimeoutError("... stream stalled ...") (#124077).
+ stall = isinstance(e, TimeoutError) and "stalled" in err
return _SummaryFailureKind(
# Permanent-looking error on a distinct summary model: fall back to main instead of cooldown.
model_not_found=status in {404, 503}
or any(m in err for m in ("model_not_found", "does not exist", "no available channel")),
- timeout=timeout,
+ timeout=stall or status in {408, 429, 502, 504} or "timeout" in err or "timed out" in err,
# Malformed/non-JSON bodies (HTML 502 as application/json) surface as JSONDecodeError or
# APIResponseValidationError "expecting value"; treat as transient.
json_decode=isinstance(e, json.JSONDecodeError) or "expecting value" in err,
# httpx premature-close errors are transient; treat like a timeout, not a 60s cooldown.
- # Anything classified as a timeout (including a "timed out"/"stalled" message on a
- # non-TimeoutError type) stays out of this class: it is a retry-ladder timeout, NOT a
- # terminal network failure that aborts compression (#124077).
- streaming_closed=_is_connection_error(e) and not timeout,
+ # Real transport timeouts stay here (terminal abort, #29559/#94448); only the stream-guard
+ # stall is a retry-ladder timeout, not a network failure (#124077).
+ streaming_closed=_is_connection_error(e) and not stall,
# HTTP 200 with empty body from a degraded provider, plus the sibling "no usable response"
# shapes from _validate_llm_response.
empty_content=isinstance(e, RuntimeError) and any(