Skip to content

Conversation

@MackinnonBuck
Copy link
Member

@MackinnonBuck MackinnonBuck commented Oct 9, 2025

Summary

Fixes an issue where SummarizingChatReducer always removes function call content, even if it didn't get summarized.

Description

This PR makes the following changes to SummarizingChatReducer:

  1. FunctionCallContent and FunctionResultContent now get preserved in the returned message list.
  2. To avoid orphaning assistant responses from their user messages, the reducer searches backward within the threshold window for a user message boundary, keeping up to targetCount + threshold messages.

Fixes #6890

Microsoft Reviewers: Open in CodeFlow

@MackinnonBuck MackinnonBuck requested a review from a team as a code owner October 9, 2025 23:26
@MackinnonBuck MackinnonBuck requested review from Copilot and removed request for a team October 9, 2025 23:26
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Oct 9, 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

Fixes an issue in SummarizingChatReducer where function call content was being removed even when not summarized. The PR preserves function call and result content in the returned message list and improves message boundary detection to avoid orphaning assistant responses from their user messages.

Key changes:

  • Preserves FunctionCallContent and FunctionResultContent in message lists
  • Implements backward search within threshold window for user message boundaries
  • Updates logic to keep complete function call sequences together

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/ChatReduction/SummarizingChatReducer.cs Core implementation changes to preserve function content and improve message boundary detection
test/Libraries/Microsoft.Extensions.AI.Tests/ChatReduction/SummarizingChatReducerTests.cs Updated and added tests to verify function content preservation and threshold behavior

@MackinnonBuck MackinnonBuck merged commit 4a0bf09 into main Oct 20, 2025
6 checks passed
@MackinnonBuck MackinnonBuck deleted the mbuck/fix-summarizing-chat-reducer branch October 20, 2025 21:19
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Oct 21, 2025
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Oct 21, 2025
jeffhandley pushed a commit to jeffhandley/extensions that referenced this pull request Oct 21, 2025
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.

SummarizingChatReducer removes all FunctionCallContents and FunctionResultContents

2 participants