-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: [BREAKING] Add support for multiple AIContextProviders on a ChatClientAgent #3863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET: [BREAKING] Add support for multiple AIContextProviders on a ChatClientAgent #3863
Conversation
There was a problem hiding this 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.AIContextProviderfrom single instance toAIContextProviderscollection (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 |
There was a problem hiding this 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.
dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs
Show resolved
Hide resolved
210d0b8
into
microsoft:feature-session-statebag
Motivation and Context
This is one PR in a sequence to enable having mutiple AIContextProviders as a pipeline directly on the agent.
Description
Contribution Checklist