fix: recover Codex streams with null output - #32910
Closed
bender-the-bot1k wants to merge 1 commit into
Closed
Conversation
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.
What does this PR do?
Fixes two Codex/Responses API edge cases that both surface as:
Observed in gateway logs with
provider=openai-codex,base_url=https://chatgpt.com/backend-api/codex,model=gpt-5.5.Root causes covered here:
chatgpt.com/backend-api/codexcan stream usable output, then send a terminalresponse.completedpayload withresponse.output = null.openai-pythonparses that terminal event withfor output in response.output, so the typed stream raises before Hermes can callstream.get_final_response()and backfill output.tools=Nonewhen there were no tools.openai-pythontreats that as an explicitly provided value and iterates it inside_make_tools, causing the sameNoneTypeerror before the request is sent.This PR keeps the recovery local to the Codex Responses path:
TypeErrorresponses.create(stream=True), which lets Hermes manually consume eventsresponse.output_item.doneitems or text deltasoutput=Noneto[]so downstreamresponse.output_textaccess does not crashresponse.output_textaccess in the conversation looptoolskwarg entirely when there are no toolsagent.logThis intentionally goes a little beyond the smaller duplicate fixes: it covers both the terminal null-output stream parser failure and the request-building
tools=Nonefailure, with regression tests for each.Related Issue
No issue number found. Related/overlapping open PRs found while checking for duplicates: #11182, #32884, #32888, #32890, #32891.
Type of Change
Changes Made
agent/codex_runtime.pyTypeError: 'NoneType' object is not iterablecaused by terminalresponse.output = nullresponses.create(stream=True)[]agent/conversation_loop.pyresponse.output_textaccess during Codex invalid-response diagnosticsagent/transports/codex.pytoolswhen converted Responses tools are empty/Nonetests/run_agent/test_run_agent_codex_responses.pytests/agent/transports/test_codex_transport.pytools/tool_choice/parallel_tool_callswhen no tools existHow to Test
python -m pytest tests/run_agent/test_run_agent_codex_responses.py tests/agent/transports/test_codex_transport.py -q -o 'addopts='The new tests simulate that exact typed-stream parser failure, verify fallback recovery, and verify
tools=Noneis no longer sent.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
Original observed traceback:
Focused test result: