.NET: [BREAKING] Change *Provider StateKey to list of StateKeys#4395
Merged
westey-m merged 4 commits intomicrosoft:mainfrom Mar 3, 2026
Merged
.NET: [BREAKING] Change *Provider StateKey to list of StateKeys#4395westey-m merged 4 commits intomicrosoft:mainfrom
westey-m merged 4 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the .NET agent provider abstractions to support multiple state keys per provider (rather than assuming a single key), and adjusts agent validation plus tests/samples accordingly.
Changes:
- Replace
StateKeywithStateKeys : IReadOnlyList<string>onAIContextProviderandChatHistoryProvider(and update concrete providers). - Update
ChatClientAgentvalidation logic to detect key clashes across all declared state keys. - Update unit tests and samples to use
StateKeys.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs | Switch provider state identifier to multi-key StateKeys. |
| dotnet/src/Microsoft.Agents.AI.Abstractions/ChatHistoryProvider.cs | Switch provider state identifier to multi-key StateKeys. |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Validate uniqueness/clashes across all keys (including override provider validation). |
| dotnet/src/Microsoft.Agents.AI/TextSearchProvider.cs | Implement StateKeys for TextSearchProvider. |
| dotnet/src/Microsoft.Agents.AI/Memory/ChatHistoryMemoryProvider.cs | Implement StateKeys for ChatHistoryMemoryProvider. |
| dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatHistoryProvider.cs | Implement StateKeys for InMemoryChatHistoryProvider. |
| dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs | Implement StateKeys for CosmosChatHistoryProvider. |
| dotnet/src/Microsoft.Agents.AI.Mem0/Mem0Provider.cs | Implement StateKeys for Mem0Provider. |
| dotnet/src/Microsoft.Agents.AI.FoundryMemory/FoundryMemoryProvider.cs | Implement StateKeys for FoundryMemoryProvider. |
| dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowChatHistoryProvider.cs | Implement StateKeys for WorkflowChatHistoryProvider. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Memory/ChatHistoryMemoryProviderTests.cs | Update assertions to StateKeys. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/Data/TextSearchProviderTests.cs | Update assertions to StateKeys. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs | Update tests/messages for new key validation behavior. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_BackgroundResponsesTests.cs | Update mocks to provide StateKeys. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_ChatHistoryManagementTests.cs | Update mocks to provide StateKeys. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AIContextProviderDecorators/AIContextProviderChatClientTests.cs | Update test provider override to StateKeys. |
| dotnet/tests/Microsoft.Agents.AI.Mem0.UnitTests/Mem0ProviderTests.cs | Update assertions to StateKeys. |
| dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs | Update assertions to StateKeys. |
| dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/InMemoryChatHistoryProviderTests.cs | Update assertions to StateKeys. |
| dotnet/samples/01-get-started/04_memory/Program.cs | Update sample provider override to StateKeys. |
| dotnet/samples/02-agents/Agents/Agent_Step04_3rdPartyChatHistoryStorage/Program.cs | Update sample provider override to StateKeys. |
dotnet/src/Microsoft.Agents.AI.Abstractions/ChatHistoryProvider.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs
Outdated
Show resolved
Hide resolved
SergeyMenshykh
approved these changes
Mar 2, 2026
dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs
Outdated
Show resolved
Hide resolved
rogerbarreto
approved these changes
Mar 3, 2026
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
It's not good to assume that AIContextProviders and ChatHistoryProviders will only use a single state key. This is especially relevant if one of these becomes a proxy for multiple internal providers, in which case each would have their own keys, and these would all need to be surfaced.
Description
string StateKeytoIReadOnlyList<string> StateKeysto allow multiple state keys per *provider.Contribution Checklist