-
Notifications
You must be signed in to change notification settings - Fork 863
HostedToolSearchTool with DeferredTools in the type #7471
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
Open
jozkee
wants to merge
27
commits into
main
Choose a base branch
from
copilot/tool-search-v2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 22 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
475d067
Implement HostedToolSearchTool and SearchableAIFunctionDeclaration fo…
Copilot 8e7c59b
Redesign: consolidate tool search into HostedToolSearchTool with Defe…
Copilot bf6107a
Address review feedback: fix O(N²), remove json baseline entry, refac…
Copilot 40f3432
Extract shared FindToolSearchTool helper to deduplicate lookup code
Copilot 5997a6a
Simplify ToResponseTool: add ChatOptions-only overload, make FindTool…
Copilot 7f3893f
Add unit tests for HostedToolSearchTool JSON serialization and integr…
Copilot 4ad7331
Revert to SearchableAIFunctionDeclaration design, remove DeferredTool…
Copilot 74f0c51
Address review feedback: rename namespaceName to @namespace, add open…
Copilot 2b39eb9
Update tests
jozkee 78f7d57
revert namespace param rename
jozkee 8e24e6f
Remove Namespace from SearchableAIFunctionDeclaration and DeferLoadin…
jozkee 8ddecb8
Remove [Experimental] from tool search types and add API baselines
jozkee f53ca13
Add integration tests for tool search edge cases
jozkee 1822466
Merge remote-tracking branch 'upstream/main' into copilot/add-tool-se…
jozkee 87f81ff
Add namespace support to SearchableAIFunctionDeclaration and namespac…
jozkee ba60cd3
Feedback
jozkee 89d8df4
Remove Namespace from SearchableAIFunctionDeclaration and namespace g…
Copilot 0579b05
Revert "Remove Namespace from SearchableAIFunctionDeclaration and nam…
Copilot 3a28bd0
Fix CI: replace KeyValuePair deconstruction for net462/netstandard2.0…
Copilot 9da8171
Add DeferredTools/Namespace on HostedToolSearchTool, support MCP tools
jozkee 44631fb
Address tool-search reviewer feedback for docs and lookup performance
Copilot 9a3e39d
Refine HostedToolSearchTool docs to use deferrable tool wording
Copilot cc2e021
Optimize tool-search lookup precomputation in OpenAI responses client
Copilot f764760
Add tests for non-deferrable tools with HostedToolSearchTool
jozkee eef8946
Bring back Experimental
jozkee f8138e1
Address test feedback
jozkee 09b89e6
Drop ChatOptions parameter from AsOpenAIResponseTool(AITool)
jozkee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/Libraries/Microsoft.Extensions.AI.Abstractions/Tools/HostedToolSearchTool.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Collections.Generic; | ||
|
|
||
| namespace Microsoft.Extensions.AI; | ||
|
|
||
| /// <summary>Represents a hosted tool that can be specified to an AI service to enable it to search for and selectively load tool definitions on demand.</summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// This tool does not itself implement tool search. It is a marker that can be used to inform a service | ||
| /// that tool search should be enabled, reducing token usage by deferring full tool schema loading until the model requests it. | ||
| /// </para> | ||
| /// <para> | ||
| /// By default, when a <see cref="HostedToolSearchTool"/> is present in the tools list, all other deferrable tools | ||
| /// are treated as having deferred loading enabled. Use <see cref="DeferredTools"/> to control which tools have deferred loading | ||
| /// on a per-tool basis. | ||
| /// </para> | ||
| /// </remarks> | ||
| public class HostedToolSearchTool : AITool | ||
| { | ||
| /// <summary>Any additional properties associated with the tool.</summary> | ||
| private IReadOnlyDictionary<string, object?>? _additionalProperties; | ||
|
|
||
| /// <summary>Initializes a new instance of the <see cref="HostedToolSearchTool"/> class.</summary> | ||
| public HostedToolSearchTool() | ||
| { | ||
| } | ||
|
|
||
| /// <summary>Initializes a new instance of the <see cref="HostedToolSearchTool"/> class.</summary> | ||
| /// <param name="additionalProperties">Any additional properties associated with the tool.</param> | ||
| public HostedToolSearchTool(IReadOnlyDictionary<string, object?>? additionalProperties) | ||
| { | ||
| _additionalProperties = additionalProperties; | ||
| } | ||
|
|
||
| /// <inheritdoc /> | ||
| public override string Name => "tool_search"; | ||
|
|
||
| /// <inheritdoc /> | ||
| public override IReadOnlyDictionary<string, object?> AdditionalProperties => _additionalProperties ?? base.AdditionalProperties; | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the list of tool names for which deferred loading should be enabled. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// The default value is <see langword="null"/>, which enables deferred loading for all deferrable tools in the tools list. | ||
| /// </para> | ||
| /// <para> | ||
| /// When non-null, only deferrable tools whose names appear in this list will have deferred loading enabled. | ||
| /// </para> | ||
| /// </remarks> | ||
| public IList<string>? DeferredTools { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the namespace name under which deferred tools should be grouped. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// <para> | ||
| /// When non-null, all deferred tools are wrapped inside a <c>{"type":"namespace","name":"..."}</c> | ||
| /// container. Non-deferred tools remain as top-level tools. | ||
| /// </para> | ||
| /// <para> | ||
| /// When <see langword="null"/> (the default), deferred tools are sent as top-level tools | ||
| /// with <c>defer_loading</c> set individually. | ||
| /// </para> | ||
| /// </remarks> | ||
| public string? Namespace { get; set; } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.