fix(agent): recover Responses streams with null output - #32913
Closed
clarkchen wants to merge 1 commit into
Closed
Conversation
This was referenced May 27, 2026
Collaborator
Author
@alt-glitch Thanks — confirmed, this duplicates #32884. Closing this PR in favor of that one. |
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
Recover Codex/OpenAI Responses streams when the terminal
response.outputisnull/Noneeven though earlier stream events already delivered output items or text deltas.This is the same failure mode described in #11179 and the same direction as #11182, adapted to this fork's current runtime split where the main Codex Responses stream lives in
agent/codex_runtime.pyrather than directly inrun_agent.py.Root Cause
Some Responses backends can emit valid
response.output_item.doneorresponse.output_text.deltaevents, then finish with a terminal response whoseoutputfield isnull. The OpenAI SDK may raiseTypeError: 'NoneType' object is not iterablewhile processing that terminal event, before Hermes can read the final response normally.Changes
agent/codex_runtime.py.NoneTypeiteration crashes using collected output items or text deltas.output=Nonethe same as empty output in thecreate(stream=True)fallback.output=Noneterminal responses.Validation
uv run --with pytest --with pytest-timeout --with pytest-asyncio python -m pytest tests/run_agent/test_run_agent_codex_responses.py tests/agent/test_auxiliary_client.py245 passed in 65.41s