fix(codex): recover from NoneType crash when response.output is null on stream completion - #32923
Closed
cathrynlavery wants to merge 1 commit into
Closed
Conversation
…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
19 tasks
Collaborator
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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