Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
No unresolved blocking issues were identified.
Review effort: Lite
Findings: None
What changed in this PR
Updates Responses message conversion to preserve raw ResponseItem and ResponseContentPart representations in system and developer messages.
Changes:
- Added raw-representation-aware conversion and ordering.
- Added tests for system/developer messages and mixed content.
| File | Description |
|---|---|
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs |
Verifies raw parts, items, and ordering. |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs |
Preserves raw instruction content during conversion. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Collaborator
🎉 Good job! The coverage increased 🎉
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1613832&view=codecoverage-tab |
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.
Why
OpenAIResponsesChatClientrebuilds a system or developer message fromChatMessage.Text, so aResponseContentPartorResponseItemset asRawRepresentationon its contents never reaches the request. User messages already send both as is, andOpenAIChatClientdoes the same for system and developer messages.This is how a caller sets a provider field that
Microsoft.Extensions.AIdoes not model on a system prompt, such as the prompt cache breakpoint in #7679.Change
When any content of a system or developer message carries a raw
ResponseItemorResponseContentPart, the message is converted as a user message is: raw items are yielded as they are, raw parts and text become the parts of the message item, and parts between yielded items are grouped into their own item to keep the order. Contents that are neither raw nor text are left out, as before.A system or developer message without raw contents is converted exactly as before.
Fixes #7679
Microsoft Reviewers: Open in CodeFlow