Repository navigation
Python: fix: streamed chat completions with n>1 produce separate messages (Fixes #9779) - #9805
Closed
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
Closed
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
Dhruv Shaswat (Dhruv-Sh-git) wants to merge 1 commit into
Conversation
Dhruv Shaswat (Dhruv-Sh-git)
deployed
to
github-app-auth
October 28, 2026 17:00 — with
GitHub Actions
Active
Dhruv Shaswat (Dhruv-Sh-git)
deployed
to
github-app-auth
October 28, 2026 17:00 — with
GitHub Actions
Active
Dhruv Shaswat (Dhruv-Sh-git)
deployed
to
github-app-auth
October 28, 2026 17:02 — with
GitHub Actions
Active
Dhruv Shaswat (Dhruv-Sh-git)
deployed
to
github-app-auth
October 28, 2026 17:02 — with
GitHub Actions
Active
Dhruv Shaswat (Dhruv-Sh-git)
marked this pull request as ready for review
October 28, 2026 17:02
Dhruv Shaswat (Dhruv-Sh-git)
deployed
to
github-app-auth
October 28, 2026 17:03 — with
GitHub Actions
Active
Member
|
We do not support N > 1, closing this. |
This branch was successfully deployed
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.
Fixes #9779. "fix: streamed chat completions with n>1 produce separate messages" --body "
What problem does this PR solve?
When a Chat Completions request uses n > 1, the OpenAI streaming client merged deltas from all choices into a single ChatResponseUpdate. This caused the final response to contain interleaved text instead of separate messages.
For example:
The non-streaming path already returns a separate message for each choice.
Root cause
_parse_response_update_from_openai() aggregated contents from all chunk.choices using contents.extend(choice_contents). This lost the separation between parallel completions before ChatResponse.from_updates could assemble the final messages.
Changes made
Why this fixes the issue
Each choice now produces its own ChatResponseUpdate with a distinct message ID. ChatResponse.from_updates can therefore group updates correctly and build one assistant message per choice, matching the non-streaming behavior.
Testing
Additional notes