Skip to content

Conversation

stephentoub
Copy link
Member

@stephentoub stephentoub commented Sep 19, 2025

Following the same pattern as elsewhere in M.E.AI, this enables a consumer to reach through layers of delegating tools to grab information from inner ones, such as whether they were marked as requiring approval.

cc: @westey-m, @rogerbarreto

Microsoft Reviewers: Open in CodeFlow

@stephentoub stephentoub requested a review from a team as a code owner September 19, 2025 22:24
@Copilot Copilot AI review requested due to automatic review settings September 19, 2025 22:24
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Sep 19, 2025
Copy link
Contributor

@Copilot 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 adds a GetService method to the AITool base class to enable retrieval of services from tools, including the ability to reach through delegating tool layers to access inner services. This follows a consistent pattern used elsewhere in the Microsoft.Extensions.AI library.

  • Added GetService method with both generic and non-generic overloads to AITool base class
  • Updated delegating classes to forward GetService calls to their inner implementations
  • Modified existing code to use the new service retrieval pattern instead of direct type checking

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs Adds the core GetService functionality to the AITool base class
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunction.cs Implements GetService delegation to inner function
src/Libraries/Microsoft.Extensions.AI.Abstractions/Functions/DelegatingAIFunctionDeclaration.cs Implements GetService delegation to inner function declaration
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs Updates approval-required function detection to use GetService pattern
src/Libraries/Microsoft.Extensions.AI.OpenAI/OpenAIResponsesChatClient.cs Implements GetService in ResponseToolAITool to expose wrapped ResponseTool
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Tools/AIToolTests.cs Adds comprehensive tests for the new GetService functionality
test/Libraries/Microsoft.Extensions.AI.Abstractions.Tests/Functions/DelegatingAIFunctionTests.cs Tests GetService delegation in DelegatingAIFunction
test/Libraries/Microsoft.Extensions.AI.OpenAI.Tests/OpenAIConversionTests.cs Tests GetService functionality with ResponseTool wrapping
src/Libraries/Microsoft.Extensions.AI.Abstractions/Microsoft.Extensions.AI.Abstractions.json Updates API surface documentation for new methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Following the same pattern as elsewhere in M.E.AI, this enables a consumer to reach through layers of delegating tools to grab information from inner ones, such as whether they were marked as requiring approval.
@stephentoub stephentoub enabled auto-merge (squash) September 19, 2025 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants