Repository navigation
Fix OpenAIResponsesChatClient streaming metadata to prevent model output merging into tool messages - #7970
Draft
caigen wants to merge 3 commits into
Conversation
…put merging into tool messages Request 3690118926c84f2b909b78b0af06015b; repair round 0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
There are no active review issues for the change that defaults early streaming updates to the Assistant role.
No open issues 🎉
What changed in this PR
Fixes #7954 by defaulting early OpenAI Responses streaming updates to the Assistant role, preventing model output from merging into preceding tool messages during aggregation.
Changes:
- Initializes streaming role metadata to Assistant while preserving explicit roles and existing message boundaries.
- Adds eight deterministic SSE regression cases covering synchronous and asynchronous aggregation of reasoning and compaction output.
- Updates existing tests to expect Assistant rather than a null role.
| File | Description |
|---|---|
| test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIResponseClientTests.cs | Adds aggregation regressions and updates streaming role expectations. |
| src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs | Defaults streaming role metadata to Assistant. |
Review effort: Balanced
caigen
marked this pull request as draft
November 21, 2026 12:39
… out of tool messages Request 3690118926c84f2b909b78b0af06015b; repair round 8. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… out of tool messages Request 3690118926c84f2b909b78b0af06015b; repair round 0. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This branch has not been 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 #7954
Summary
Fixes #7954: early Responses streaming output could merge into a preceding tool message.
Changes
Default streaming metadata to Assistant while preserving explicit roles and message boundaries. Add eight deterministic SSE regression cases and update existing role expectations.
Validation
Local build and tests passed.
All eight regressions failed before the fix. Afterward, the affected library build and all 137 OpenAIResponseClientTests passed with normal analyzers enabled. Existing encrypted-reasoning roundtripping and function-call aggregation remain covered. No live API tests were run.
Risks
Early streaming updates intentionally report Assistant instead of null. MessageId handling and shared aggregation are unchanged.
Microsoft Reviewers: Open in CodeFlow