.Net: Bugfix OpenAI Assistant Client When Annotation comes in an empty text chunk#6723
Merged
stephentoub merged 1 commit intodotnet:mainfrom Aug 15, 2025
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the OpenAI Assistant Client where annotation information can arrive in a streaming delta chunk without accompanying text content. The fix creates an empty text chunk to hold the annotation when no text content is present.
- Adds a check for empty text content in delta chunks
- Creates an empty TextContent object when needed to attach annotations
- Ensures annotations are properly processed even when they arrive without text
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIAssistantsChatClient.cs
Show resolved
Hide resolved
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Motivation and Context
This PR fixes a bug where the annotation information can come in the streaming from a delta chunk that doesn't share a
Textchunk, to accommodate those scenarios an empty text chunk is created with the annotation attached to it.Reproduction / Test Code below works after the change.
Microsoft Reviewers: Open in CodeFlow