Skip to content

Conversation

@westey-m
Copy link
Contributor

Motivation and Context

This is one PR in a sequence to enable having mutiple AIContextProviders as a pipeline directly on the agent.

Description

  • Add support for passing multiple AIContextProviders directly to a ChatClientAgent
  • Add key checking to stop users from accidentally using the same key twice and overwriting state.

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 February 11, 2026 19:23
@github-actions github-actions bot changed the title [BREAKING] Add support for multiple AIContextProviders on a ChatClientAgent .NET: [BREAKING] Add support for multiple AIContextProviders on a ChatClientAgent Feb 11, 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

This PR introduces breaking changes to enable multiple AIContextProviders on a ChatClientAgent, replacing the single AIContextProvider property with an AIContextProviders collection. This enhancement allows agents to compose context from multiple sources in a pipeline pattern, where each provider receives and can augment the accumulated context from previous providers.

Changes:

  • Changed ChatClientAgentOptions.AIContextProvider from single instance to AIContextProviders collection (IEnumerable)
  • Added StateKey validation to prevent multiple providers from using the same key and overwriting each other's session state
  • Implemented sequential invocation of multiple providers with context accumulation
  • Updated all extension methods, samples, and tests to use the new collection-based API

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentOptions.cs Changed AIContextProvider property from single to collection, updated Clone method
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs Added StateKey validation, provider collection property, sequential invocation logic, and runtime validation for overrides
dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs Updated to use AIContextProviders collection
dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs Updated to use AIContextProviders collection
dotnet/src/Microsoft.Agents.AI.AzureAI.Persistent/PersistentAgentsClientExtensions.cs Updated to use AIContextProviders collection
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs Added comprehensive tests for StateKey validation, multiple provider invocation, and helper test classes
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentOptionsTests.cs Updated tests to use AIContextProviders collection
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_BackgroundResponsesTests.cs Updated tests to use AIContextProviders collection syntax
dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs Updated test to use AIContextProviders collection
dotnet/samples/GettingStarted/Agents/Agent_Step20_AdditionalAIContext/Program.cs Removed AggregatingAIContextProvider class, updated to use built-in multiple provider support
dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG/Program.cs Updated to use AIContextProviders collection
dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG/Program.cs Updated to use AIContextProviders collection
dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step03_CustomRAGDataSource/Program.cs Updated to use AIContextProviders collection
dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step01_ChatHistoryMemory/Program.cs Updated to use AIContextProviders collection
dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step02_MemoryUsingMem0/Program.cs Updated to use AIContextProviders collection
dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step03_CustomMemory/Program.cs Updated to use AIContextProviders collection

Copilot AI review requested due to automatic review settings February 12, 2026 11:07
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

Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.

@westey-m westey-m merged commit 210d0b8 into microsoft:feature-session-statebag Feb 12, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants