fix: recover Codex stream final parse TypeError#32891
Closed
ahmertsengol wants to merge 1 commit into
Closed
Conversation
da32929 to
fa1f970
Compare
Collaborator
This was referenced May 27, 2026
Author
|
I’m happy to either close this as duplicate, or adapt this PR to also cover auxiliary_client.py if maintainers prefer a single consolidated fix. The main value here may be the conversation-level regression coverage; I can move that over if useful. |
This was referenced May 27, 2026
19 tasks
This was referenced May 27, 2026
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. |
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 streaming edge case where the OpenAI SDK final response parser can raise:
This was observed with the
openai-codexprovider againsthttps://chatgpt.com/backend-api/codex. The stream had already produced usable assistant output, butstream.get_final_response()failed while parsing the final response. Hermes then treated the turn as a non-retryable provider/client failure even though output was available.What changed
stream.get_final_response()for the specificNoneTypefinal parse error.response.output_item.doneevents were collected, Hermes synthesizes a completed response from those output items.TypeErrors unchanged by re-raising them.Why
The Codex backend can stream valid output items/text before the SDK final parser fails. In that case, dropping the turn is worse than using the already streamed output, especially because the user may see the text but Hermes still marks the request as failed.
Observed log shape:
After the fix, the same failure mode is logged as a warning and Hermes continues with the collected streamed output.
Tests
source venv/bin/activate && python -m pytest tests/run_agent/test_run_agent_codex_responses.py -qsource venv/bin/activate && python -m pytest tests/run_agent/test_streaming.py tests/run_agent/test_codex_xai_oauth_recovery.py -q