Skip to content

fix(codex): accumulate output items from stream events#2437

Open
grearsl wants to merge 1 commit intosipeed:mainfrom
grearsl:fix/codex-streaming-empty-output
Open

fix(codex): accumulate output items from stream events#2437
grearsl wants to merge 1 commit intosipeed:mainfrom
grearsl:fix/codex-streaming-empty-output

Conversation

@grearsl
Copy link
Copy Markdown

@grearsl grearsl commented Apr 9, 2026

Summary

  • The Codex/OpenAI Responses streaming API sends output items via response.output_item.done events, but the final response.completed event arrives with an empty Output array
  • This caused all Codex OAuth provider responses to return empty content (0 content chars) despite the model successfully generating a reply (completion tokens > 0)
  • Fix accumulates output items as they stream in and merges them into the response when response.completed has none

Reproduction

  1. Configure a model with auth_method: "oauth" (Codex provider)
  2. Send any message
  3. Response returns "The model returned an empty response" despite successful API call

Root cause

In codex_provider.go, the streaming loop only captured evt.Response from terminal events (response.completed), but the OpenAI Responses API does not populate Response.Output in that event — output items are delivered separately via response.output_item.done events.

Test plan

  • Tested with gpt-5.4 via OAuth — responses now returned correctly
  • Tested with gpt-5.3-codex via OAuth — same fix applies
  • Verified tool calls and text content both parse correctly
  • No regressions on non-Codex providers (change is scoped to codex_provider.go)

🤖 Generated with Claude Code

The Codex/OpenAI Responses streaming API sends output items via
response.output_item.done events during the stream, but the final
response.completed event arrives with an empty Output array. This
caused all Codex provider responses to return empty content despite
the model successfully generating a reply.

Fix by accumulating output items as they arrive and merging them
into the response when response.completed has none.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 9, 2026

CLA assistant check
All committers have signed the CLA.

@sipeed-bot sipeed-bot bot added type: bug Something isn't working domain: provider go Pull requests that update go code labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: provider go Pull requests that update go code type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants