Skip to content

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

Merged
westey (westey-m) merged 4 commits into
microsoft:mainfrom
westey-m:make-statekey-list
Mar 3, 2026
Merged

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

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

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.

CopilotAI review requested due to automatic review settings March 2, 2026 17:04
@markwallace-microsoftMark Wallace (markwallace-microsoft) added .NET Usage: [Issues, PRs], Target: .Net workflows Usage: [Issues, PRs], Target: Workflows labels Mar 2, 2026
@github-actionsgithub-actionsBot changed the title Change *Provider StateKey to list of StateKeys.NET: Change *Provider StateKey to list of StateKeysMar 2, 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

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
FileDescription
dotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.csSwitch provider state identifier to multi-key StateKeys.
dotnet/src/Microsoft.Agents.AI.Abstractions/ChatHistoryProvider.csSwitch provider state identifier to multi-key StateKeys.
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.csValidate uniqueness/clashes across all keys (including override provider validation).
dotnet/src/Microsoft.Agents.AI/TextSearchProvider.csImplement StateKeys for TextSearchProvider.
dotnet/src/Microsoft.Agents.AI/Memory/ChatHistoryMemoryProvider.csImplement StateKeys for ChatHistoryMemoryProvider.
dotnet/src/Microsoft.Agents.AI.Abstractions/InMemoryChatHistoryProvider.csImplement StateKeys for InMemoryChatHistoryProvider.
dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.csImplement StateKeys for CosmosChatHistoryProvider.
dotnet/src/Microsoft.Agents.AI.Mem0/Mem0Provider.csImplement StateKeys for Mem0Provider.
dotnet/src/Microsoft.Agents.AI.FoundryMemory/FoundryMemoryProvider.csImplement StateKeys for FoundryMemoryProvider.
dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowChatHistoryProvider.csImplement StateKeys for WorkflowChatHistoryProvider.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Memory/ChatHistoryMemoryProviderTests.csUpdate assertions to StateKeys.
dotnet/tests/Microsoft.Agents.AI.UnitTests/Data/TextSearchProviderTests.csUpdate assertions to StateKeys.
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.csUpdate tests/messages for new key validation behavior.
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_BackgroundResponsesTests.csUpdate mocks to provide StateKeys.
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_ChatHistoryManagementTests.csUpdate mocks to provide StateKeys.
dotnet/tests/Microsoft.Agents.AI.UnitTests/AIContextProviderDecorators/AIContextProviderChatClientTests.csUpdate test provider override to StateKeys.
dotnet/tests/Microsoft.Agents.AI.Mem0.UnitTests/Mem0ProviderTests.csUpdate assertions to StateKeys.
dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.csUpdate assertions to StateKeys.
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/InMemoryChatHistoryProviderTests.csUpdate assertions to StateKeys.
dotnet/samples/01-get-started/04_memory/Program.csUpdate sample provider override to StateKeys.
dotnet/samples/02-agents/Agents/Agent_Step04_3rdPartyChatHistoryStorage/Program.csUpdate sample provider override to StateKeys.

Comment threaddotnet/src/Microsoft.Agents.AI.Abstractions/ChatHistoryProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs
Comment threaddotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs Outdated
@westey-mwestey (westey-m) changed the title .NET: Change *Provider StateKey to list of StateKeys.NET: [BREAKING] Change *Provider StateKey to list of StateKeysMar 2, 2026
Comment threaddotnet/src/Microsoft.Agents.AI.Abstractions/AIContextProvider.cs Outdated
@westey-m
westey (westey-m) added this pull request to the merge queueMar 3, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Mar 3, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueMar 3, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Mar 3, 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 d5da6e0Mar 3, 2026
19 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