Skip to content

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Sep 6, 2025

If the role changes, consider it a new message.

#6731

Microsoft Reviewers: Open in CodeFlow

If the role changes, consider it a new message.
@Copilot Copilot AI review requested due to automatic review settings September 6, 2025 03:28
@stephentoub stephentoub requested a review from a team as a code owner September 6, 2025 03:28
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Sep 6, 2025
Copy link
Contributor

@Copilot 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 enhances the ChatMessage coalescing logic to treat role changes as message boundaries. Previously, only message ID changes would trigger creation of new messages during response update processing.

  • Updates the ProcessUpdate method to check for role changes in addition to message ID changes
  • Adds comprehensive test coverage for role and message ID change scenarios
  • Fixes existing test data to maintain consistency with the new coalescing behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Libraries/Microsoft.Extensions.AI.Abstractions/ChatCompletion/ChatResponseExtensions.cs Adds role change detection logic to determine when to create new messages
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/ChatCompletion/ChatResponseUpdateExtensionsTests.cs Updates existing test and adds new comprehensive test for role/ID change scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@stephentoub stephentoub merged commit 44fbcce into dotnet:main Sep 6, 2025
7 checks passed
@stephentoub stephentoub deleted the updatecoalescing branch September 6, 2025 17:55
joperezr pushed a commit that referenced this pull request Sep 9, 2025
If the role changes, consider it a new message.
@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants