Skip to content

The agent that grows with you

refactor(compressor): key the Codex stall on the stream guard's shared marker

kshitijk4poor8c9f2162c7fe
diff --git a/agent/auxiliary_client.py b/agent/auxiliary_client.py
index 83c7fc16242..53802e8375d 100644
--- a/agent/auxiliary_client.py
+++ b/agent/auxiliary_client.py
@@ -1171,6 +1171,10 @@ def _close_quietly(target: Any, failure_note: Optional[str]) -> None:
logger.debug("Codex auxiliary: %s", failure_note, exc_info=True)
+# The context compressor keys its retry-ladder classification on this text (#124077).
+CODEX_STREAM_STALL_MARKER = "stream stalled"
+
+
class _CodexStreamGuard:
"""Progress-aware deadline + FD-safe timeout watchdog for one Codex aux stream attempt.
@@ -1272,7 +1276,7 @@ class _CodexStreamGuard:
"Codex auxiliary Responses stream produced no output "
f"within {float(self.no_progress_timeout):.1f}s (no-progress timeout, {elapsed:.1f}s elapsed)")
return (
- "Codex auxiliary Responses stream stalled: no new output "
+ f"Codex auxiliary Responses {CODEX_STREAM_STALL_MARKER}: no new output "
f"for {float(self.no_progress_timeout):.1f}s ({elapsed:.1f}s elapsed)")
def _close_client_on_timeout(self) -> None:
diff --git a/agent/context_compressor.py b/agent/context_compressor.py
index ac0bbac8ce3..87b6dab03ca 100644
--- a/agent/context_compressor.py
+++ b/agent/context_compressor.py
@@ -24,6 +24,7 @@ from agent.compression_marker import (
elide_middle,
)
from agent.auxiliary_client import (
+ CODEX_STREAM_STALL_MARKER,
AuxiliaryExplicitCancellation,
_coerce_llm_message,
_is_connection_error,
@@ -744,8 +745,9 @@ def _classify_summary_failure(e: Exception) -> _SummaryFailureKind:
"""
status = _exc_status_code(e)
err = str(e).lower()
- # The Codex aux stream guard raises TimeoutError("... stream stalled ...") (#124077).
- stall = isinstance(e, TimeoutError) and "stalled" in err
+ # The Codex aux stream guard's mid-stream stall is transient (#124077). Its no-progress and
+ # hard-ceiling timeouts deliberately stay terminal network failures.
+ stall = isinstance(e, TimeoutError) and CODEX_STREAM_STALL_MARKER 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}
diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.py
index 6ec885b2fc4..f7991dcbcb7 100644
--- a/tests/agent/test_context_compressor.py
+++ b/tests/agent/test_context_compressor.py
@@ -3708,8 +3708,10 @@ class TestSummaryFailureClassification124077:
return c
def test_codex_stall_is_ladder_timeout_not_terminal_network_failure(self):
- c = self._run_summary_failure(TimeoutError(
- "Codex auxiliary Responses stream stalled: no new output for 60.0s (67.7s elapsed)"))
+ from agent.auxiliary_client import _CodexStreamGuard
+ guard = _CodexStreamGuard(None, 300.0)
+ guard.saw_content.set() # mid-stream: content arrived, then the stream went quiet
+ c = self._run_summary_failure(TimeoutError(guard.timeout_message()))
assert c._last_summary_network_failure is False
assert c._consecutive_timeout_failures == 1