Skip to content

fix(docker): patch OpenAI SDK parse_response crash for Codex endpoint (output: null) - #33553

Closed
cesarcruz28 wants to merge 1 commit into
NousResearch:mainfrom
cesarcruz28:fix/openai-sdk-parse-response-none
Closed

fix(docker): patch OpenAI SDK parse_response crash for Codex endpoint (output: null)#33553
cesarcruz28 wants to merge 1 commit into
NousResearch:mainfrom
cesarcruz28:fix/openai-sdk-parse-response-none

Conversation

@cesarcruz28

Copy link
Copy Markdown

Problem

OpenAI Python SDK >=2.37.0\ introduced a regression in \parse_response():

\\python

openai/lib/_parsing/_responses.py line ~61

for output in response.output: # 💥 TypeError when output is None
\\

The ChatGPT Codex endpoint (\chatgpt.com/backend-api/codex) always returns \output: null\ in the final
esponse.completed\ SSE event when \store=false\ — and \store: false\ is required (the API rejects \store: true\ with 400). This means every Codex/gpt-5.5 response crashes with:

\
TypeError: 'NoneType' object is not iterable
\\

The exception is caught upstream as a local validation error and the agent silently returns nothing, so the user only sees Hermes greet them but never reply.

Fix

One-line Python guard applied in the same \RUN\ as \uv sync\ — patching in a later \RUN\ silently no-ops because \pathlib.rglob\ cannot traverse into cached overlay layers from a prior \RUN.

\\python
'for output in response.output:'
→ 'for output in (response.output or []):'
\\

This is the minimal safe guard: an empty list short-circuits the loop cleanly, and the existing backfill logic in _run_codex_stream()\ already handles the empty-output case.

Upstream fix

The correct long-term fix is for OpenAI to ship SDK >=2.37.1\ with the None guard. This patch ensures Docker users are not broken in the meantime regardless of which SDK version \uv\ resolves to.

🤖 Generated with Claude Code

openai SDK >=2.37.0 introduced a regression in parse_response() at
openai/lib/_parsing/_responses.py:

    for output in response.output:   # crashes when output is None

The ChatGPT Codex endpoint (chatgpt.com/backend-api/codex) returns
output: null in the final response.completed SSE event when store=false,
which is required (the API rejects store:true with 400). This causes
TypeError: 'NoneType' object is not iterable on every Codex response,
making hermes silently fail to reply.

Fix: in the same RUN as uv sync, apply a one-line guard in-place so the
patch is always in the same Docker layer as the install — applying it in
a separate RUN after a cached install layer silently no-ops because
pathlib.rglob cannot traverse into cached overlay layers.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have area/docker Docker image, Compose, packaging provider/openai OpenAI / Codex Responses API codex labels May 28, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

The canonical fix for Codex null output was already merged in #32963, and a structural refactor (#33042) dropped responses.stream() entirely, eliminating this bug class in-process. This PR only patches the Dockerfile's vendored SDK copy — the in-process fix is already in tree.

@cesarcruz28

Copy link
Copy Markdown
Author

Great! thanks!

@cesarcruz28
cesarcruz28 deleted the fix/openai-sdk-parse-response-none branch May 28, 2026 00:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docker Docker image, Compose, packaging codex P3 Low — cosmetic, nice to have provider/openai OpenAI / Codex Responses API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants