-
Notifications
You must be signed in to change notification settings - Fork 950
.NET: Address gap IServiceProvider support for provider extensions #2551
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: Address gap IServiceProvider support for provider extensions #2551
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 addresses issue #505 by adding comprehensive IServiceProvider support to provider extension methods across the codebase. The changes enable users to pass service providers through the extension APIs so that AI functions can resolve required services during invocation.
- Adds
IServiceProvider? servicesparameter to allCreateAIAgentandGetAIAgentextension methods - Ensures the service provider is correctly propagated through the call chain to
ChatClientAgentconstructors - Includes comprehensive unit tests verifying the service provider is passed to the underlying
FunctionInvokingChatClient
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIResponseClientExtensions.cs | Added services parameter to both CreateAIAgent overloads and passed through to ChatClientAgent constructor |
| dotnet/src/Microsoft.Agents.AI.OpenAI/Extensions/OpenAIAssistantClientExtensions.cs | Added services parameter to all CreateAIAgent, GetAIAgent, and async variants, propagating through the entire call chain |
| dotnet/src/Microsoft.Agents.AI.AzureAI.Persistent/PersistentAgentsClientExtensions.cs | Added services parameter to all CreateAIAgent, GetAIAgent methods and their async variants with consistent propagation |
| dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Extensions/OpenAIResponseClientExtensionsTests.cs | Added three comprehensive tests verifying services parameter handling and reflection helper method |
| dotnet/tests/Microsoft.Agents.AI.OpenAI.UnitTests/Extensions/OpenAIAssistantClientExtensionsTests.cs | Added four tests covering services parameter in different method variants plus helper classes |
| dotnet/tests/Microsoft.Agents.AI.AzureAI.Persistent.UnitTests/Extensions/PersistentAgentsClientExtensionsTests.cs | Added five tests for services parameter with both sync and async methods, plus minor code cleanup improvement |
Motivation and Context