Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.NET: Add AggregateAIContextProvider (or support for multiple AIContextProviders) to .NET implementation for parity with Python version #2933

Description

@WarlockZhang

Description:

In the Python implementation, when multiple context providers are passed to the agent constructor (e.g., context_providers=[provider1, provider2]), the framework automatically creates an AggregateContextProvider that aggregates them. This allows seamless combination of multiple providers (e.g., memory + RAG + custom state) without manual merging.
In the .NET implementation (Microsoft.Agents.AI), the ChatClientAgentOptions.AIContextProviderFactory only accepts a single AIContextProvider. There is no built-in AggregateAIContextProvider (or equivalent) class, and no automatic aggregation when multiple providers are needed.
Just like this in Python samples


   # Create multiple context providers

   provider1 = CustomContextProvider1()

   provider2 = CustomContextProvider2()

   provider3 = CustomContextProvider3()

   # Pass them to the agent - AggregateContextProvider is created automatically

   agent = ChatAgent(chat_client=client, name="assistant", context_providers=[provider1, provider2, provider3])

   # Verify that an AggregateContextProvider was created

   assert isinstance(agent.context_providers, AggregateContextProvider)

   # Add additional providers to the agent

   provider4 = CustomContextProvider4()

   agent.context_providers.add(provider4)

Metadata

Metadata

Assignees

Labels

.NETUsage: [Issues, PRs], Target: .NetagentsUsage: [Issues, PRs], Target: Single agentmemoryUsage: [Issues, PRs], Target: memory related features

Type

No type

Fields

No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions