-
Notifications
You must be signed in to change notification settings - Fork 841
Fix coalescing of TextReasoningContent with ProtectedData #6936
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
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 fixes a bug in the coalescing logic for TextReasoningContent objects that contain ProtectedData. The issue was that when merging consecutive TextReasoningContent items, the ProtectedData from the last item in a merge sequence was not being preserved in the coalesced result.
Key changes:
- Updated the merge factory function to preserve
ProtectedDatafrom the last item in a merge sequence - Added debug assertions to validate merge preconditions
- Added comprehensive test coverage for the new coalescing behavior with
ProtectedData
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
ChatResponseExtensions.cs |
Fixed the coalescing logic to preserve ProtectedData from the last item when merging TextReasoningContent, and added debug assertions |
ChatResponseUpdateExtensionsTests.cs |
Added test case verifying correct coalescing behavior when TextReasoningContent items have ProtectedData |
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs
Show resolved
Hide resolved
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs
Show resolved
Hide resolved
jeffhandley
left a comment
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.
I appreciate the Debug.Asserts there.
Microsoft Reviewers: Open in CodeFlow