fix: harden codex responses preflight and stream error handling - #4313
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvage of #4283 by @curtitoo (cherry-picked onto current main).
Fixes two real gaps in the Codex Responses API path:
tools=Nonein preflight —_preflight_codex_api_kwargs()unconditionally included"tools": normalized_toolsin the request dict. When no tools were configured, this sent"tools": nullto the API. Fix: only include the key whennormalized_tools is not None.Transport error handling in
_run_codex_stream()— The method only caughtRuntimeError(for missingresponse.completed). httpx transport errors (RemoteProtocolError,ReadTimeout,ConnectError) escaped entirely, unlike the chat completions streaming path which has comprehensive httpx error handling. Fix: catch transport errors, retry once, then fall back to_run_codex_create_stream_fallback().Verification
pytest tests/test_streaming.py— 20/20 pass (including 2 new codex tests)pytest tests/test_run_agent.py tests/test_codex_execution_paths.py tests/test_provider_parity.py— 294/294 passgpt-5.3-codexviachatgpt.com/backend-api/codex:completed=True, response=Four(previously would have senttools=null)completed=True, response=Four(regression check)Closes #4283.