Skip to content

fix: harden codex responses preflight and stream error handling - #4313

Merged
teknium1 merged 2 commits into
mainfrom
hermes/hermes-3090d6ac
Mar 31, 2026
Merged

fix: harden codex responses preflight and stream error handling#4313
teknium1 merged 2 commits into
mainfrom
hermes/hermes-3090d6ac

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Salvage of #4283 by @curtitoo (cherry-picked onto current main).

Fixes two real gaps in the Codex Responses API path:

  1. tools=None in preflight_preflight_codex_api_kwargs() unconditionally included "tools": normalized_tools in the request dict. When no tools were configured, this sent "tools": null to the API. Fix: only include the key when normalized_tools is not None.

  2. Transport error handling in _run_codex_stream() — The method only caught RuntimeError (for missing response.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 pass
  • Live E2E with Codex API — tested both fixes against gpt-5.3-codex via chatgpt.com/backend-api/codex:
    • No tools: completed=True, response=Four (previously would have sent tools=null)
    • With tools: completed=True, response=Four (regression check)

Closes #4283.

@teknium1
teknium1 merged commit cac9d20 into main Mar 31, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants