.NET: [BREAKING] Trim final FRC to match service storage#4792
Open
westey-m wants to merge 6 commits intomicrosoft:mainfrom
Open
.NET: [BREAKING] Trim final FRC to match service storage#4792westey-m wants to merge 6 commits intomicrosoft:mainfrom
westey-m wants to merge 6 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Aligns ChatHistoryProvider-backed chat history with service-side storage by trimming trailing FunctionResultContent when tool loops terminate, with an opt-out flag.
Changes:
- Added
ChatClientAgentRunOptions.StoreFinalFunctionResultContent(experimental) to control persistence of trailingFunctionResultContent. - Implemented response trimming of trailing tool-only
FunctionResultContentbefore persisting to chat history (and currently also before AI context notification). - Added unit tests covering non-streaming/streaming behavior and cloning behavior for the new run option.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Filters trailing tool FunctionResultContent before notifying history/context providers. |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentRunOptions.cs | Adds the nullable StoreFinalFunctionResultContent run option with detailed remarks. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentRunOptionsTests.cs | Ensures the new run option is cloned correctly. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_StoreFinalFunctionResultContentTests.cs | Adds coverage for persistence trimming behavior (incl. streaming). |
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentRunOptions.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ilterFinalFunctionResultContent to use IList
TaoChenOSU
approved these changes
Mar 19, 2026
4 tasks
4 tasks
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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
#4791
Currently there is a mismatch in behavior between service stored chat history and ChatHistoryProvider stored chat history when function tools are terminated. This brings those behaviors into sync, with an opt out.
Also not notifying AIContextProviders to match chat history storage.
This change is a behavioral break, but only for very limited circumstances, e.g. when using function call termination.
Description
Contribution Checklist