Skip to content

[BREAKING] Add response filter for store input in *Providers - #4327

Merged
westey (westey-m) merged 6 commits into
microsoft:mainfrom
westey-m:add-store-input-response-filter
Mar 3, 2026
Merged

[BREAKING] Add response filter for store input in *Providers#4327
westey (westey-m) merged 6 commits into
microsoft:mainfrom
westey-m:add-store-input-response-filter

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation and Context

#4256

Description

  • Add filter for response messages when storing messages in ChatMessageProviders and AIContextProviders

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

CopilotAI review requested due to automatic review settings February 26, 2026 17:21
@markwallace-microsoftMark Wallace (markwallace-microsoft) added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Feb 26, 2026
@github-actionsgithub-actionsBot changed the title Add response filter for store input in *Providers.NET: Add response filter for store input in *ProvidersFeb 26, 2026

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds separate filtering for request vs. response messages when providers store/learn from an invocation, enabling scenarios like excluding tool/function-call messages from persisted chat history (Issue #4256).

Changes:

  • Split “store input” filtering into StorageInputRequestMessageFilter and StorageInputResponseMessageFilter across chat-history and AI-context provider pipelines.
  • Update concrete providers/options (TextSearch, ChatHistoryMemory, Mem0, FoundryMemory, Cosmos/InMemory chat history) to pass the new filters through.
  • Update unit tests and samples to use the new request/response filter APIs.

Reviewed changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated 13 comments.

Show a summary per file
FileDescription
dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.csIntroduces request/response store filters in the base provider invocation pipeline.
dotnet/src/Microsoft.Agents.AI.Abstractions/ChatHistoryProvider.csIntroduces request/response store filters for chat history storage.
dotnet/src/Microsoft.Agents.AI.Abstractions/MessageAIContextProvider.csThreads new request/response store filters through message-based context providers.
dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatHistoryProviderOptions.csAdds request/response storage filter options for in-memory chat history.
dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatHistoryProvider.csWires new options into the base ChatHistoryProvider constructor.
dotnet/src/Microsoft.Agents.AI/TextSearchProviderOptions.csAdds request/response storage filters for TextSearchProvider state updates.
dotnet/src/Microsoft.Agents.AI/TextSearchProvider.csPasses the new filters into the base class.
dotnet/src/Microsoft.Agents.AI/Memory/ChatHistoryMemoryProviderOptions.csAdds request/response storage filters for chat-history-backed memory.
dotnet/src/Microsoft.Agents.AI/Memory/ChatHistoryMemoryProvider.csPasses the new filters into the base class.
dotnet/src/Microsoft.Agents.AI.Mem0/Mem0ProviderOptions.csAdds request/response storage filters for Mem0 extraction.
dotnet/src/Microsoft.Agents.AI.Mem0/Mem0Provider.csPasses the new filters into the base class.
dotnet/src/Microsoft.Agents.AI.FoundryMemory/FoundryMemoryProviderOptions.csAdds request/response storage filters for Foundry memory extraction.
dotnet/src/Microsoft.Agents.AI.FoundryMemory/FoundryMemoryProvider.csPasses the new filters into the base class.
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.csAdds request/response storage filter parameters and forwards them to the base class.
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowChatHistoryProvider.csRemoves now-stale base ctor call; relies on new default ctor parameters.
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AIContextProviderTests.csAdds/updates tests validating request/response filter behavior.
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/ChatHistoryProviderTests.csUpdates tests to validate filtered response storage behavior.
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/InMemoryChatHistoryProviderTests.csUpdates tests to use the renamed request filter option.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Data/TextSearchProviderTests.csUpdates tests to use the renamed request filter option.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Memory/ChatHistoryMemoryProviderTests.csUpdates tests to use the renamed request filter option.
dotnet/tests/Microsoft.Agents.AI.Mem0.UnitTests/Mem0ProviderTests.csUpdates tests to use the renamed request filter option.
dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.csUpdates tests for renamed ctor parameter and new semantics.
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_ChatHistoryManagementTests.csUpdates mocks due to updated base ctor signatures.
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_BackgroundResponsesTests.csUpdates mocks due to updated base ctor signatures.
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.csUpdates mocks due to updated base ctor signatures.
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentOptionsTests.csUpdates mocks due to updated base ctor signatures.
dotnet/samples/02-agents/Agents/Agent_Step17_AdditionalAIContext/Program.csUpdates sample to use the renamed request filter option.
dotnet/samples/02-agents/Agents/Agent_Step04_3rdPartyChatHistoryStorage/Program.csRemoves stale base ctor call after signature change.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG/Program.csUpdates sample to use the renamed request filter option.
dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG/Program.csUpdates sample to use the renamed request filter option.
dotnet/samples/01-get-started/04_memory/Program.csRemoves stale base ctor call after signature change.

Comment threaddotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI/Memory/ChatHistoryMemoryProviderOptions.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI/TextSearchProviderOptions.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs Outdated
@westey-mwestey (westey-m) changed the title .NET: Add response filter for store input in *Providers[BREAKING] Add response filter for store input in *ProvidersFeb 26, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment threaddotnet/src/Microsoft.Agents.AI.Abstractions/ChatHistoryProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs Outdated
Co-authored-by: SergeyMenshykh <68852919+SergeyMenshykh@users.noreply.github.com>
@westey-m
westey (westey-m) added this pull request to the merge queueMar 2, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Mar 2, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueMar 3, 2026
Merged via the queue into microsoft:main with commit 945933cMar 3, 2026
18 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NETUsage: [Issues, PRs], Target: .NetworkflowsUsage: [Issues, PRs], Target: Workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@westey-m@rogerbarreto@SergeyMenshykh@markwallace-microsoft