Skip to content

Fix /v1/responses streaming: emit full OpenAI Responses API event sequence - #57

Merged
Sophomoresty merged 1 commit into
Sophomoresty:mainfrom
121212165:fix-responses-stream-events
Aug 1, 2026
Merged

Fix /v1/responses streaming: emit full OpenAI Responses API event sequence#57
Sophomoresty merged 1 commit into
Sophomoresty:mainfrom
121212165:fix-responses-stream-events

Conversation

@121212165

Copy link
Copy Markdown
Contributor

Problem

When calling POST /v1/responses with "stream": true, the server only emits three events: response.created -> response.output_text.done -> response.completed.

Clients built on the official OpenAI SDK (and most third-party clients) parse the Responses API stream with a strict state machine. They require response.output_item.added and response.content_part.added before any text event, and render text from response.output_text.delta. Without these events the whole output is discarded and the user sees an empty reply ("no content returned"), even though the HTTP status is 200.

Fix

Emit the complete standard event sequence:

response.created
response.in_progress
response.output_item.added
response.content_part.added
response.output_text.delta
response.output_text.done
response.content_part.done
response.output_item.done
response.completed
  • Added sequence_number and output_index fields to every event
  • function_call items also get output_item.added / function_call_arguments.delta / output_item.done
  • Non-streaming path unchanged

Testing

Verified locally on Windows (Python 3.12):

  • stream: false unchanged, returns completed response
  • stream: true now emits all 9 events in order; a client that previously showed "no content" renders replies correctly after this fix

…uence

The stream previously only sent response.created, response.output_text.done and response.completed. Clients built on the official OpenAI SDK use a strict streaming state machine and require response.output_item.added / response.content_part.added / response.output_text.delta events; without them they discard the output and show an empty reply. Emit the complete standard event sequence with sequence_number and output_index, for both message and function_call items.
@Sophomoresty
Sophomoresty merged commit 2bae912 into Sophomoresty:main Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants