Skip to content

Conversation

@stephentoub
Copy link
Member

@stephentoub stephentoub commented Oct 18, 2025

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

For Assistant and Tool messages we're directly roundtripping RawRepresentations that are ResponseItems, but not for User messages. Fix that.
@stephentoub stephentoub requested a review from jozkee October 18, 2025 01:10
@stephentoub stephentoub requested a review from a team as a code owner October 18, 2025 01:10
Copilot AI review requested due to automatic review settings October 18, 2025 01:10
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Oct 18, 2025
Copy link
Contributor

Copilot AI left a 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.

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.
@stephentoub stephentoub requested a review from Copilot October 18, 2025 12:08
Copy link
Contributor

Copilot AI left a 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.

@stephentoub stephentoub merged commit 1dc5b31 into dotnet:main Oct 18, 2025
6 checks passed
@stephentoub stephentoub deleted the roundtripraw branch October 18, 2025 12:09
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Oct 21, 2025
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.
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Oct 21, 2025
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.
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Oct 21, 2025
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.
This was referenced Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants