Fix /v1/responses streaming: emit full OpenAI Responses API event sequence - #57
Merged
Sophomoresty merged 1 commit intoAug 1, 2026
Merged
Conversation
…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.
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.
Problem
When calling
POST /v1/responseswith"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.addedandresponse.content_part.addedbefore any text event, and render text fromresponse.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:
sequence_numberandoutput_indexfields to every eventfunction_callitems also getoutput_item.added/function_call_arguments.delta/output_item.doneTesting
Verified locally on Windows (Python 3.12):
stream: falseunchanged, returns completed responsestream: truenow emits all 9 events in order; a client that previously showed "no content" renders replies correctly after this fix