[codex] recover from SDK NoneType stream errors - #32937
Closed
llwhite1 wants to merge 1 commit into
Closed
Conversation
llwhite1
marked this pull request as ready for review
May 27, 2026 02:03
Collaborator
Author
|
Thanks for pointing me to #32884. Agreed that the main One difference here is that this PR also applies the same recovery pattern to |
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. |
7 tasks
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
Fixes a Codex Responses streaming failure where the OpenAI SDK can raise
TypeError: 'NoneType' object is not iterableafter the ChatGPT Codex backend has already streamed usable output.The main Codex runtime and auxiliary Codex adapter now recover only when stream content has already been collected. They synthesize the final response from streamed output items or text deltas so Hermes does not abort after a successful Codex generation.
Root Cause
The
chatgpt.com/backend-api/codexstreaming path can emit validresponse.output_text.delta/response.output_item.doneevents, but SDK stream iteration or finalization can still raise aNoneTypeiterableTypeError. Previously Hermes treated that as a non-retryable client error even though the model output was already available.Validation
./venv/bin/python -m pytest tests/run_agent/test_run_agent_codex_responses.py::test_run_codex_stream_recovers_from_iteration_nonetype_after_text_delta tests/run_agent/test_run_agent_codex_responses.py::test_run_codex_stream_recovers_from_finalization_nonetype_after_output_item tests/agent/test_auxiliary_client.py::TestCodexAuxiliaryAdapterTimeout::test_recovers_from_iteration_nonetype_after_text_delta -qscripts/run_tests.sh tests/run_agent/test_run_agent_codex_responses.py tests/agent/test_auxiliary_client.pyhermes chat -q "Reply exactly: OK" --provider openai-codex -m gpt-5.5 --ignore-rules -QNotes
The recovery remains narrow: unrelated
TypeErrors still propagate, and this path only synthesizes a completed response when Hermes has already observed usable streamed output.