Skip to content

fix(codex): recover from NoneType crash when response.output is null on stream completion - #32923

Closed
cathrynlavery wants to merge 1 commit into
NousResearch:mainfrom
cathrynlavery:fix/codex-nonetype-stream-recovery
Closed

fix(codex): recover from NoneType crash when response.output is null on stream completion#32923
cathrynlavery wants to merge 1 commit into
NousResearch:mainfrom
cathrynlavery:fix/codex-nonetype-stream-recovery

Conversation

@cathrynlavery

Copy link
Copy Markdown

OpenAI Codex can stream valid response.output_item.done frames but omit response.output on the final response.completed frame. openai-python then raises TypeError while parsing the completed frame — before Hermes can use the data it already received.

Because TypeError is classified as a local validation error (is_local_validation_error), the conversation loop treats it as non-retryable and aborts immediately instead of falling back.

This patch catches that specific TypeError in run_codex_stream and reassembles the response from collected_output_items (preferred) or _codex_streamed_text_parts (text-delta fallback) — the same recovery paths already used for empty response.output. Unrelated TypeErrors are re-raised unchanged.

Verified in production: logs show "Codex stream completed without response.output; recovering from N streamed output items" instead of hard failures.

Refs: #11179, #21444

…on stream completion

OpenAI Codex can stream valid response.output_item.done frames but
omit response.output on the final response.completed frame.
openai-python then raises TypeError("'NoneType' object is not
iterable") while parsing the completed frame — before Hermes can use
the data it already received.

Because TypeError is classified as a local validation error
(is_local_validation_error), the conversation loop treats it as
non-retryable and aborts immediately instead of falling back.

This patch catches that specific TypeError in run_codex_stream and
reassembles the response from collected_output_items (preferred) or
_codex_streamed_text_parts (text-delta fallback) — the same recovery
paths already used for empty response.output.

Unrelated TypeErrors are re-raised unchanged.

Refs: NousResearch#11179, NousResearch#21444
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint provider/openai OpenAI / Codex Responses API codex duplicate This issue or pull request already exists labels May 27, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #32884 — same Codex Responses null output recovery. Root cause tracked in #11179.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as duplicate — the Codex null-output fix has been merged via #32963 (cherry-picked from @carltonawong's PR #32890, the one Gille reviewed). Thanks for jumping on the outage so quickly; appreciate the help. Closes #11179.

@teknium1 teknium1 closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex 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/openai OpenAI / Codex Responses API type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants