-
Notifications
You must be signed in to change notification settings - Fork 841
Update AsOpenAIResponseItems to roundtrip User AIContent ResponseItems #6931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For Assistant and Tool messages we're directly roundtripping RawRepresentations that are ResponseItems, but not for User messages. Fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Rounds out OpenAI response item conversion so that AIContent.RawRepresentation values that are full ResponseItem instances in user messages are directly round‑tripped (previously only done for assistant/tool messages).
- Adds a new switch case in ToOpenAIResponseItems to yield RawRepresentation when it is a ResponseItem.
- Introduces a unit test validating roundtrip behavior for several ResponseItem types in user and assistant messages.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs | Adds a new unit test to assert raw ResponseItem roundtripping from user/assistant messages. |
| src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs | Adds a switch case to emit RawRepresentation directly when it is a ResponseItem. |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
Previously a ResponseItem between two TextContents, for example, would end up being yielded before the text content that came before it. Instead, yield a response item for each group between directly-mapped items. Also fix missing RawRepresentation on McpServerToolApprovalResponseContent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Show resolved
Hide resolved
dotnet#6931) * Update AsOpenAIResponseItems to roundtrip User AIContent ResponseItems For Assistant and Tool messages we're directly roundtripping RawRepresentations that are ResponseItems, but not for User messages. Fix that. * Ensure ordering of AIContent-to-ResponseItem mapping Previously a ResponseItem between two TextContents, for example, would end up being yielded before the text content that came before it. Instead, yield a response item for each group between directly-mapped items. Also fix missing RawRepresentation on McpServerToolApprovalResponseContent.
dotnet#6931) * Update AsOpenAIResponseItems to roundtrip User AIContent ResponseItems For Assistant and Tool messages we're directly roundtripping RawRepresentations that are ResponseItems, but not for User messages. Fix that. * Ensure ordering of AIContent-to-ResponseItem mapping Previously a ResponseItem between two TextContents, for example, would end up being yielded before the text content that came before it. Instead, yield a response item for each group between directly-mapped items. Also fix missing RawRepresentation on McpServerToolApprovalResponseContent.
dotnet#6931) * Update AsOpenAIResponseItems to roundtrip User AIContent ResponseItems For Assistant and Tool messages we're directly roundtripping RawRepresentations that are ResponseItems, but not for User messages. Fix that. * Ensure ordering of AIContent-to-ResponseItem mapping Previously a ResponseItem between two TextContents, for example, would end up being yielded before the text content that came before it. Instead, yield a response item for each group between directly-mapped items. Also fix missing RawRepresentation on McpServerToolApprovalResponseContent.
For Assistant and Tool messages we're directly roundtripping RawRepresentations that are ResponseItems, but not for User messages. Fix that.
Microsoft Reviewers: Open in CodeFlow