Skip to content

fix(codex): handle null output field in OpenAI SDK parse_response - #32959

Closed
tiagofrigini wants to merge 1 commit into
NousResearch:mainfrom
tiagofrigini:fix/codex-output-null-patch
Closed

tiagofrigini wants to merge 1 commit into
NousResearch:mainfrom
tiagofrigini:fix/codex-output-null-patch

Conversation

@tiagofrigini

Copy link
Copy Markdown

Problem

The chatgpt.com/backend-api/codex endpoint recently started sending SSE stream events (e.g. response.output_text.delta, response.output_item.done) with "output": null instead of "output": [].

The OpenAI SDK's parse_response() (lib/_parsing/_responses.py) iterates over response.output without a None guard, causing:

TypeError: 'NoneType' object is not iterable

This broke all codex_responses API calls unconditionally.

Fix

Apply an idempotent monkey-patch at import time in agent/codex_responses_adapter.py that coerces response.output = None to [] before delegating to the original parse_response().

Verification

  • Reproduced locally with gpt-5.4 on https://chatgpt.com/backend-api/codex — 100% failure rate before patch, 0% after.
  • Patch is gated to only fire when output is None, so it is harmless when the backend reverts to [].

Closes #32956

The chatgpt.com/backend-api/codex endpoint started sending SSE stream
events (response.output_text.delta, response.output_item.done, etc.)
with "output": null instead of "output": []. The OpenAI SDK's
parse_response() (lib/_parsing/_responses.py) iterates over
response.output without a None guard, raising:

    TypeError: 'NoneType' object is not iterable

This caused all Codex Responses API calls to fail unconditionally.

Apply an idempotent monkey-patch at import time in the adapter module
that coerces response.output = None to [] before delegating to the
original parse_response().

Closes NousResearch#32956
@tiagofrigini
tiagofrigini deleted the fix/codex-output-null-patch branch May 27, 2026 02:35
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have provider/copilot GitHub Copilot (ACP + Chat) comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists labels May 27, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

Duplicate of #32963 (merged) which already landed the Codex null-output stream recovery fix. Root cause: #11179.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have provider/copilot GitHub Copilot (ACP + Chat) type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Codex Responses streaming crashes with TypeError: 'NoneType' object is not iterable (openai-codex / chatgpt.com backend)

2 participants