The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: widen APIConnectionError handling to finalization drain loop
kshitij10b2b11efae6
diff --git a/agent/codex_runtime.py b/agent/codex_runtime.pyindex 65cc3cd1a0d..e098751d980 100644--- a/agent/codex_runtime.py+++ b/agent/codex_runtime.py@@ -1489,7 +1489,25 @@ def run_codex_stream(agent, api_kwargs: dict, client: Any = None, on_first_deltatry:for _ignored in event_stream:pass- except (_httpx.RemoteProtocolError, _httpx.ReadTimeout, _httpx.ConnectError, ConnectionError) as exc:+ except (+ _httpx.RemoteProtocolError,+ _httpx.ReadTimeout,+ _httpx.ConnectError,+ ConnectionError,+ ) as exc:+ logger.warning(+ "Codex Responses stream transport finalization failed "+ "after a terminal response was already received; "+ "returning the completed response instead of "+ "retrying. %s error=%s",+ agent._client_log_context(), exc,+ )+ except _APIConnectionError as exc:+ _log_codex_request_failure(+ agent,+ exc,+ stream_opened=writer_token["value"] is not None,+ )logger.warning("Codex Responses stream transport finalization failed ""after a terminal response was already received; "diff --git a/tests/agent/test_codex_request_transport_diagnostics.py b/tests/agent/test_codex_request_transport_diagnostics.pyindex 0cb4567d2a3..0a65155baf5 100644--- a/tests/agent/test_codex_request_transport_diagnostics.py+++ b/tests/agent/test_codex_request_transport_diagnostics.py@@ -59,3 +59,5 @@ def test_transport_failure_logs_exact_request_bytes_and_class_chain(caplog):assert "stream_opened=false" in messageassert "exception_chain=APIConnectionError <- RemoteProtocolError" in messageassert "payload" not in message+ assert request_content.decode() not in message+ assert "example.invalid" not in message