Skip to content

Conversation

@rogerbarreto
Copy link
Member

@rogerbarreto rogerbarreto self-assigned this Dec 1, 2025
Copilot AI review requested due to automatic review settings December 1, 2025 12:50
@github-actions github-actions bot changed the title .Net: Address gap IServiceProvider support for provider extensions .NET: Address gap IServiceProvider support for provider extensions Dec 1, 2025
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 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? services parameter to all CreateAIAgent and GetAIAgent extension methods
  • Ensures the service provider is correctly propagated through the call chain to ChatClientAgent constructors
  • 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

@rogerbarreto rogerbarreto added this pull request to the merge queue Dec 1, 2025
Merged via the queue into microsoft:main with commit 8ae33d3 Dec 1, 2025
14 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.

.NET: IChatClient's service provider lost when using ChatAgentClient, breaking custom AITool implementations

3 participants