Skip to content

Conversation

@crickman
Copy link
Contributor

@crickman crickman commented Nov 20, 2025

Enable the following logic to handle cases for processing streaming updates without an AIContent abstraction (RawRepresentation only):

In the absence of this additional logic, the following conversion results in an empty ChatMessage:

Microsoft Reviewers: Open in CodeFlow

@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Nov 20, 2025
@crickman
Copy link
Contributor Author

@crickman please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree company="Microsoft"

@crickman crickman marked this pull request as ready for review November 21, 2025 19:02
@crickman crickman requested a review from a team as a code owner November 21, 2025 19:02
Copilot AI review requested due to automatic review settings November 21, 2025 19:02
Copilot finished reviewing on behalf of crickman November 21, 2025 19:05
@crickman crickman changed the title DRAFT Proposal - Streaming Response Item OpenAI Responses - Add default handler for streaming updates Nov 21, 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

This PR adds a generic fallback handler for streaming response items that don't have dedicated AIContent abstractions, addressing the issue where certain streaming updates would result in empty ChatMessage objects. The solution introduces a HashSet to track types with explicit handlers and provides a catch-all case to wrap unhandled items in AIContent with RawRepresentation.

Key changes:

  • Adds _responseItemTypesWithHandlers HashSet to track response item types with dedicated handlers
  • Removes the specific case for McpToolDefinitionListItem (line 419-422)
  • Adds a generic handler for StreamingResponseOutputItemDoneUpdate that creates AIContent with RawRepresentation for types not explicitly handled elsewhere

@stephentoub stephentoub changed the title OpenAI Responses - Add default handler for streaming updates Ensure all ResponseItems are yielded in AIContent Nov 22, 2025
@stephentoub stephentoub enabled auto-merge (squash) November 22, 2025 04:30
@stephentoub stephentoub merged commit b4d61c8 into dotnet:main Nov 22, 2025
6 checks passed
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.

2 participants