-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Support overriding built-in tools #636
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5c977f1
Initial plan
Copilot 94e9daa
feat: Support overriding built-in tools (Issue #411)
Copilot 282a297
test: add E2E tests and scenario for tool overrides
patniko 2ff53d3
fix: address review findings from PR #523
patniko 21f595e
style: fix ruff formatting in Python test_client.py
patniko b49777e
chore: update snapshot from E2E run
patniko 17b567b
Replace excludedTools merging with overridesBuiltInTool flag
SteveSandersonMS 6e56f47
chore: clean up leftover mergeExcludedTools artifacts
SteveSandersonMS bf6c792
refactor: replace BuiltInToolOverrides with AdditionalProperties, rem…
SteveSandersonMS bf8840b
chore: remove InternalsVisibleTo and redundant unit test, fix overloa…
SteveSandersonMS 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
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
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,61 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (c) Microsoft Corporation. All rights reserved. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| using Microsoft.Extensions.AI; | ||
| using System.ComponentModel; | ||
| using System.Text.Json; | ||
| using Xunit; | ||
|
|
||
| namespace GitHub.Copilot.SDK.Test; | ||
|
|
||
| public class OverridesBuiltInToolTests | ||
| { | ||
| [Fact] | ||
| public void ToolDefinition_FromAIFunction_Sets_OverridesBuiltInTool() | ||
| { | ||
| var fn = AIFunctionFactory.Create(Noop, "grep"); | ||
| var def = CopilotClient.ToolDefinition.FromAIFunction(fn, overridesBuiltInTool: true); | ||
|
|
||
| Assert.Equal("grep", def.Name); | ||
| Assert.True(def.OverridesBuiltInTool); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ToolDefinition_FromAIFunction_Omits_OverridesBuiltInTool_When_False() | ||
| { | ||
| var fn = AIFunctionFactory.Create(Noop, "custom_tool"); | ||
| var def = CopilotClient.ToolDefinition.FromAIFunction(fn, overridesBuiltInTool: false); | ||
|
|
||
| Assert.Equal("custom_tool", def.Name); | ||
| Assert.Null(def.OverridesBuiltInTool); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void SessionConfig_BuiltInToolOverrides_Is_Used() | ||
| { | ||
| var config = new SessionConfig | ||
| { | ||
| Tools = new List<AIFunction> { AIFunctionFactory.Create(Noop, "grep") }, | ||
| BuiltInToolOverrides = new HashSet<string> { "grep" }, | ||
| }; | ||
|
|
||
| Assert.Contains("grep", config.BuiltInToolOverrides); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ResumeSessionConfig_BuiltInToolOverrides_Is_Used() | ||
| { | ||
| var config = new ResumeSessionConfig | ||
| { | ||
| Tools = new List<AIFunction> { AIFunctionFactory.Create(Noop, "grep") }, | ||
| BuiltInToolOverrides = new HashSet<string> { "grep" }, | ||
| }; | ||
|
|
||
| Assert.NotNull(config.BuiltInToolOverrides); | ||
| Assert.Contains("grep", config.BuiltInToolOverrides!); | ||
| } | ||
|
|
||
| [Description("No-op")] | ||
| static string Noop() => ""; | ||
| } |
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
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.
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.
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.
Is there a way to query for all built-in tools?
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.
Not currently. Can you say what the use case would be?
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.
I'm wondering if there's a) a way I can proactively determine whether I'm going to get conflicts with built-in tools or if it'll just be "oops, that one conflicts now, better change it" and b) whether I can determine what tools are in use to see whether I might want to replace one with my own logic.
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.
OK thanks for explaining. I suspect even then it might be tricky to make a programmatic decision since it would depend on understanding the semantics and usage patterns of the built-in tool. But we can certainly consider adding a way to enumerate them if we get demand for it.