fix(agent): recover Codex streams with null output

This commit is contained in:
Carlton 2026-05-26 17:15:01 -07:00 committed by Teknium
parent bb4703c761
commit 43a3f119fc
4 changed files with 250 additions and 62 deletions

View file

@ -2554,6 +2554,45 @@ class TestCodexAuxiliaryAdapterTimeout:
assert time.monotonic() - started < 0.14
class TestCodexAuxiliaryAdapterNullOutputRecovery:
def test_recovers_output_item_when_sdk_raises_during_iteration(self):
"""Regression for #11179 in auxiliary calls such as compression/title generation."""
output_item = SimpleNamespace(
type="message",
content=[SimpleNamespace(type="output_text", text="aux survived")],
)
class NullOutputParseStream:
def __enter__(self):
return self
def __exit__(self, exc_type, exc, tb):
return False
def __iter__(self):
yield SimpleNamespace(type="response.output_item.done", item=output_item)
raise TypeError("'NoneType' object is not iterable")
def get_final_response(self): # pragma: no cover - iterator fails first
raise AssertionError("get_final_response should not be reached")
class FakeResponses:
def __init__(self):
self.create = MagicMock()
def stream(self, **kwargs):
return NullOutputParseStream()
fake_client = SimpleNamespace(responses=FakeResponses())
adapter = _CodexCompletionsAdapter(fake_client, "gpt-5.5")
response = adapter.create(messages=[{"role": "user", "content": "summarize"}])
assert response.choices[0].message.content == "aux survived"
fake_client.responses.create.assert_not_called()
# ---------------------------------------------------------------------------
# Issue #23432 — auxiliary timeout poisons cached client; later aux calls fail
# ---------------------------------------------------------------------------