Skip to content

The agent that grows with you

test: restore agent-lane aux/compressor regression guards dropped by #120071

teknium121cc9de8c930
diff --git a/tests/agent/test_aux_progress_streaming.py b/tests/agent/test_aux_progress_streaming.py
index fe6b573812f..26e7b9c8449 100644
--- a/tests/agent/test_aux_progress_streaming.py
+++ b/tests/agent/test_aux_progress_streaming.py
@@ -522,6 +522,28 @@ class TestContentBearingProgress:
accumulator.feed(_chunk(content="token"))
assert fence.seconds_since_progress() < 0.05
+ def test_content_free_frames_still_record_ttfp_timing(self):
+ """The fast-lane telemetry contract (#96945/#96963) survives the
+ #96707 gating: the provider-response (time_to_first_progress_ms)
+ hook must fire on the FIRST frame of any kind (transport liveness),
+ not only on the first token."""
+ from agent.auxiliary_client import (
+ _aux_provider_response,
+ _aux_thread_local_hook,
+ )
+
+ responses: list = []
+ keepalive = SimpleNamespace(id=None, model=None, choices=[], usage=None)
+ accumulator = _ChatStreamAccumulator()
+
+ with (
+ _aux_thread_local_hook(_aux_provider_response, lambda: responses.append("response")),
+ aux_progress_hook(lambda: None),
+ ):
+ accumulator.feed(keepalive)
+
+ assert responses, "content-free first frame must still record TTFP"
+
# ---------------------------------------------------------------------------
diff --git a/tests/agent/test_auxiliary_client.py b/tests/agent/test_auxiliary_client.py
index 2a0f8aa4b3b..eb0615db56c 100644
--- a/tests/agent/test_auxiliary_client.py
+++ b/tests/agent/test_auxiliary_client.py
@@ -3859,6 +3859,27 @@ class TestCodexAuxiliaryAdapterCompletedResponse:
assert response.usage.completion_tokens == 3
assert response.usage.total_tokens == 14
+ def test_completed_response_with_null_output_does_not_crash(self):
+ """Regression for #33368: a host that returns a completed Responses
+ object with ``output=None`` must yield an empty ``stop`` turn, not
+ ``TypeError: 'NoneType' object is not iterable``."""
+ completed = SimpleNamespace(
+ status="completed", id="r", output=None, output_text="", usage=None,
+ incomplete_details=None, error=None,
+ )
+
+ class FakeResponses:
+ def create(self, **kwargs):
+ return completed
+
+ fake_client = SimpleNamespace(responses=FakeResponses())
+ adapter = _CodexCompletionsAdapter(fake_client, "gpt-5.5")
+
+ response = adapter.create(messages=[{"role": "user", "content": "x"}])
+
+ assert response.choices[0].message.content is None
+ assert response.choices[0].finish_reason == "stop"
+
class TestCodexAuxiliaryAdapterReservedToolAliases:
"""The aux adapter emits the same tool schemas as the main Responses transport: shared
diff --git a/tests/agent/test_context_compressor.py b/tests/agent/test_context_compressor.py
index 5fb15d933bd..4c60d58e81b 100644
--- a/tests/agent/test_context_compressor.py
+++ b/tests/agent/test_context_compressor.py
@@ -1186,6 +1186,41 @@ class TestSummaryFallbackToMainModel:
+class TestStreamingClosedFailure:
+ """httpcore / httpx premature stream-close errors are transient transport
+ failures, not generic summary errors (#18458): they get the short
+ cooldown and flag a network failure so compress() preserves the session,
+ instead of the long generic cooldown. Drives the real classifier."""
+
+ def _msgs(self):
+ return [
+ {"role": "user", "content": "do something"},
+ {"role": "assistant", "content": "ok"},
+ ]
+
+ def _fail_on_main(self, err):
+ with patch("agent.context_compressor.get_model_context_length", return_value=100000):
+ c = ContextCompressor(model="main-model", quiet_mode=True)
+ with patch("agent.context_compressor.call_llm", side_effect=err), \
+ patch("agent.context_compressor.time.monotonic", return_value=1000.0):
+ result = c._generate_summary(self._msgs())
+ assert result is None
+ return c
+
+ @pytest.mark.parametrize("message", [
+ "RemoteProtocolError: incomplete chunked read",
+ "RemoteProtocolError: response ended prematurely",
+ ])
+ def test_premature_stream_close_is_transient_network_failure(self, message):
+ closed = self._fail_on_main(Exception(message))
+ generic = self._fail_on_main(Exception("something unexpected broke"))
+
+ assert closed._last_summary_network_failure is True
+ assert generic._last_summary_network_failure is False
+ # Short transient cooldown, strictly below the generic-failure cooldown.
+ assert 1000.0 < closed._summary_failure_cooldown_until < generic._summary_failure_cooldown_until
+
+
class TestAuxModelFallbackSurfacedToCallers:
"""When summary_model fails but retry-on-main succeeds, compress() must
expose the aux-model failure via _last_aux_model_failure_{model,error}