Skip to content

fix(codex): handle None response.output from SDK get_final_response (fixes #32908) - #32919

Closed
Morad37 wants to merge 2 commits into
NousResearch:mainfrom
Morad37:fix/32908-codex-none-output
Closed

fix(codex): handle None response.output from SDK get_final_response (fixes #32908)#32919
Morad37 wants to merge 2 commits into
NousResearch:mainfrom
Morad37:fix/32908-codex-none-output

Conversation

@Morad37

@Morad37 Morad37 commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

When the Codex backend omits the response.completed terminal event, the OpenAI SDK's parse_response() crashes with TypeError: 'NoneType' object is not iterable at line 61 of _parsing/_responses.py - because response.output is None instead of []. This TypeError bypasses the existing backfill logic at codex_runtime.py:250-273 designed exactly for this scenario.

Fix

Catch TypeError on stream.get_final_response() and set output=[] on a minimal response object. The existing backfill then reconstructs output from already-collected stream items (collected_output_items) or synthesized text deltas - preserving data and avoiding a fresh API call (no double-billing).

The existing exception handler at line 302 caught RuntimeError but not TypeError, so the crash jumped past every recovery path and escalated as a non-retryable client error.

Testing

Bug is reproducible with hermes chat -q "say the word ok" --provider openai-codex -m gpt-5.5 (45+ times per session per the reporter).

Closes #32908

@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 null output recovery. Competing with #32888, #32890, #32891, #32897, #32898, #32900, #32901, #32913, #32914, #32915, #32918, #32920. Root cause: #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). Thanks for the help during the outage. 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

3 participants