Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add AITool.GetService - #6830

#6830
Merged
stephentoub merged 3 commits into
dotnet:maindotnet/extensions:mainfrom
stephentoub:aitoolgetservicestephentoub/extensions:aitoolgetserviceCopy head branch name to clipboard
Sep 24, 2025
Merged

Add AITool.GetService#6830
stephentoub merged 3 commits into
dotnet:maindotnet/extensions:mainfrom
stephentoub:aitoolgetservicestephentoub/extensions:aitoolgetserviceCopy head branch name to clipboard

Conversation

@stephentoub

@stephentoub stephentoub commented Sep 19, 2025

Copy link
Copy Markdown
Member

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 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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

Comment thread src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs
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
Comment thread src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/AITool.cs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.