fix(codex): use terminal event response when get_final_response has empty output#6026
Open
dontcallmejames wants to merge 1 commit into
Open
Conversation
…mpty output When _run_codex_stream() calls stream.get_final_response(), the resulting response object can have an empty output list even when the stream's terminal event (response.completed) carried a fully-populated response object. Capture event.response from terminal stream events and prefer it over get_final_response() when the latter returns empty output. Fixes NousResearch#5883
Collaborator
Collaborator
|
Likely duplicate of #5720 — same root cause: Codex Responses stream returns empty output, fix captures terminal event response as fallback. |
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.
Bug (closes #5883)
GPT-5.4 via openai-codex fails in normal mode with "Empty/malformed response"
but works in verbose mode. The root cause: when
stream.get_final_response()returns an emptyoutputlist, the existingbackfill logic (from
output_item.doneevents and text-delta synthesis) canfail silently in normal mode. However, the terminal stream event
(
response.completed) carries a fully-populated response object inevent.responsethat is never captured.Fix
event.responsefor all terminal stream events(
response.completed,response.incomplete,response.failed).get_final_response(), prefer the terminal event's response whenget_final_response()has empty output but the terminal event carriesvalid output.
This is the same approach as open PR #5720, implemented cleanly against the
current upstream.
Testing
tests/run_agent/test_run_agent_codex_responses.pypasses (35 tests).Closes #5883