-
Notifications
You must be signed in to change notification settings - Fork 843
Ensure all ResponseItems are yielded in AIContent #7063
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
@dotnet-policy-service agree company="Microsoft" |
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs
Outdated
Show resolved
Hide resolved
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
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
_responseItemTypesWithHandlersHashSet to track response item types with dedicated handlers - Removes the specific case for
McpToolDefinitionListItem(line 419-422) - Adds a generic handler for
StreamingResponseOutputItemDoneUpdatethat createsAIContentwithRawRepresentationfor types not explicitly handled elsewhere
Enable the following logic to handle cases for processing streaming updates without an AIContent abstraction (
RawRepresentationonly):In the absence of this additional logic, the following conversion results in an empty
ChatMessage:-https://github.com/dotnet/extensions/blob/main/src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs#L485
Microsoft Reviewers: Open in CodeFlow