Skip to content

.NET: [BREAKING] Change *Provider StateKey to list of StateKeys#4395

Merged
westey-m merged 4 commits intomicrosoft:mainfrom
westey-m:make-statekey-list
Mar 3, 2026
Merged

.NET: [BREAKING] Change *Provider StateKey to list of StateKeys#4395
westey-m merged 4 commits intomicrosoft:mainfrom
westey-m:make-statekey-list

Conversation

@westey-m
Copy link
Contributor

@westey-m westey-m commented Mar 2, 2026

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

  • Change string StateKey to IReadOnlyList<string> StateKeys to allow multiple state keys per *provider.
  • Update implementations and tests.

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.

Copilot AI review requested due to automatic review settings March 2, 2026 17:04
@markwallace-microsoft markwallace-microsoft added .NET workflows Related to Workflows in agent-framework labels Mar 2, 2026
@github-actions github-actions bot changed the title Change *Provider StateKey to list of StateKeys .NET: Change *Provider StateKey to list of StateKeys Mar 2, 2026
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

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 StateKey with StateKeys : IReadOnlyList<string> on AIContextProvider and ChatHistoryProvider (and update concrete providers).
  • Update ChatClientAgent validation 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.

@westey-m westey-m changed the title .NET: Change *Provider StateKey to list of StateKeys .NET: [BREAKING] Change *Provider StateKey to list of StateKeys Mar 2, 2026
@westey-m westey-m added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2026
@westey-m westey-m added this pull request to the merge queue Mar 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 3, 2026
@westey-m westey-m added this pull request to the merge queue Mar 3, 2026
Merged via the queue into microsoft:main with commit d5da6e0 Mar 3, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants