fix(codex): recover from SDK none-output iterator crash - #33279
Closed
ahmadashfq wants to merge 2 commits into
Closed
fix(codex): recover from SDK none-output iterator crash#33279ahmadashfq wants to merge 2 commits into
ahmadashfq wants to merge 2 commits into
Conversation
Collaborator
Contributor
|
Thanks for this — closing as already fixed on The Codex null-output crash (
Your fix targets the same path that's now hardened upstream, so there's nothing left to merge here. Your authorship is preserved in your branch; I'm crediting your report in the umbrella issue #33932 (now closed). Appreciate the contribution. |
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.
Summary
Fix the remaining
openai-codexstreamed Responses crash when the OpenAI SDKraises
TypeError: 'NoneType' object is not iterableafterchatgpt.comreturns a terminal snapshot with
response.output = null.This supersedes the old branch-level fix in #33138. That PR targeted the
pre-
agent/codex_runtime.pylayout; the current mainline still hits the sameSDK iterator crash because
responses.create(stream=True)continues to run theSDK accumulator while yielding events.
Fixes #33237.
What changed
agent/codex_runtime._consume_codex_event_stream()when theSDK iterator raises the null-output
TypeErrorafter streamedresponse.output_item.done/response.output_text.deltaevents alreadyarrived
final response from the streamed state already collected before the crash
they share
_consume_codex_event_stream()HTTP Nonefallback messaging with the actual exceptionclass and summarized error text (
TypeError, etc.)Why this is still needed after the raw-event migration
The current code correctly avoids reconstructing content from
response.completed.response.output, but the OpenAI SDK's streamed iteratorstill performs its own accumulator work internally while we iterate over
responses.create(stream=True). That means the SDK can still throw thenull-output
TypeErrorafter Hermes has already received valid streameditems. The right Hermes-side fix is therefore to recover from the streamed
state instead of assuming raw iteration is structurally immune.
Verification
Ran locally with the project venv:
./venv/bin/python -m pytest tests/run_agent/test_run_agent_codex_responses.py -k 'null_output or none_output_typeerror'./venv/bin/python -m pytest tests/agent/test_auxiliary_client.py -k 'NullOutputRecovery or none_output_typeerror'./venv/bin/python -m pytest tests/run_agent/test_run_agent.py -k 'nonretryable_error_kind'All passed.