fix(chat): respect context key expressions for tool visibility#303663
Open
swg0101 wants to merge 1 commit intomicrosoft:mainfrom
Open
fix(chat): respect context key expressions for tool visibility#303663swg0101 wants to merge 1 commit intomicrosoft:mainfrom
swg0101 wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes tool visibility consistent by applying when context key expressions to both getTools() (UI) and getAllToolsIncludingDisabled() (extension API / $getTools), preventing context-hidden tools from being sent to language model providers.
Changes:
- Apply
whenclause filtering ingetAllToolsIncludingDisabled()to matchgetTools(). - Ensure tools with
when: "false"are excluded from the tool list surfaced via the extension API.
src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts
Show resolved
Hide resolved
ff446ca to
8986470
Compare
The `when` clause in `languageModelTools` contributions was only being applied to `getTools()` (used by UI), not `getAllToolsIncludingDisabled()` (used by the extension API via `$getTools`). This caused tools like `configure_python_notebook` and `restart_notebook_kernel` with `when: "false"` to be hidden from the tools panel but still appear in the available tools list sent to language models. Now both methods consistently filter by the `when` context key expression. Tested with the unify-chat-provider with verbose set to true and with a custom agent with tools: []. Confirmed that the tools block is no longer being sent to LLM providers. Added new unit test to test new behavior. Fixes microsoft#292260
8986470 to
98ee672
Compare
Author
|
@microsoft-github-policy-service agree |
Contributor
|
@connor4312 you added Could the implementation of |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
whenclause inlanguageModelToolscontributions was only being applied togetTools()(used by UI), notgetAllToolsIncludingDisabled()(used by the extension API via$getTools).This caused tools like
configure_python_notebookandrestart_notebook_kernelwithwhen: "false"to be hidden from the tools panel but still appear in the available tools list sent to language models.Now both methods consistently filter by the
whencontext key expression.Tested with the unify-chat-provider with verbose set to true and with a custom agent with
tools: []. Confirmed that the tools block is no longer being sent to LLM providers.Fixes #292260