src/vs/workbench/contrib/chat/common/chatSelectedModel.ts

241 LOC · 148 covered · 93 uncovered · 21 ranges · 61 concepts · 8 introducers · 36 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the related-file, concept, and source links on this page.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the filerunSubagentTool.ts ×1 · 2 introduced LOCrunSubagentTool.ts ×1runSubagentTool.test|title=RunSubagentTool subagent credits writes the running credit total onto the subagent toolSpecificData|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.ts ×1 · 9 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×4 · 15 introduced LOCrunSubagentTool.ts ×4runSubagentTool.ts ×1 · 3 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×1 · 2 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×2 · 20 introduced LOCrunSubagentTool.ts ×2runSubagentTool.ts ×2 · 2 introduced LOCrunSubagentTool.ts ×2runSubagentTool.ts ×16 · 146 introduced LOCrunSubagentTool.ts ×16runSubagentTool.test|title=RunSubagentTool model fallback behavior skips Copilot fallback but uses a non-Copilot fallback when main model is BYOK|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior skips Copilot fallback models when main model is BYOK and inherits the main model|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…promptsServiceUtils.ts ×2 · 5 introduced LOCpromptsServiceUtils.ts ×…runSubagentTool.test|title=RunSubagentTool model fallback behavior throws error when subagent model has higher multiplier|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error when explicit model has higher multiplier|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when it has equal multiplier|occurrence=1, runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when it has lower multiplier|occurrence=1, +3 · 0 introduced LOCrunSubagentTool.test|tit…promptsServiceUtils.ts ×1 · 2 introduced LOCpromptsServiceUtils.ts ×…runSubagentTool.ts ×4 · 11 introduced LOCrunSubagentTool.ts ×4runSubagentTool.test|title=RunSubagentTool model fallback behavior uses the Copilot fallback model when the main model is also Copilot|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…promptsServiceUtils.ts ×2 · 2 introduced LOCpromptsServiceUtils.ts ×…runSubagentTool.test|title=RunSubagentTool explicit model parameter explicit model overrides agent configured model|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error with available models when explicit model is not found|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses the Copilot fallback model when no main model is set|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…chatSelectedModel.ts ×1 · 2 introduced LOCchatSelectedModel.ts ×1runSubagentTool.ts ×1 · 3 introduced LOCrunSubagentTool.ts ×1runSubagentTool.test|title=RunSubagentTool model fallback behavior uses main model when subagent has no model configured|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.ts ×2 · 13 introduced LOCrunSubagentTool.ts ×2mockLanguageModelToolsService.ts ×1 · 2 introduced LOCmockLanguageModelToolsSe…runSubagentTool.test|title=RunSubagentTool explicit model parameter resolves explicit model parameter without agentName|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.ts ×4 · 30 introduced LOCrunSubagentTool.ts ×4runSubagentTool.ts ×1 · 2 introduced LOCrunSubagentTool.ts ×1runSubagentTool.test|title=RunSubagentTool prepareToolInvocation returns correct toolSpecificData|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses main model when no subagent is specified|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.ts ×2 · 3 introduced LOCrunSubagentTool.ts ×2runSubagentTool.ts ×1 · 2 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×1 · 3 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×2 · 3 introduced LOCrunSubagentTool.ts ×2runSubagentTool.test|title=RunSubagentTool prepareToolInvocation passes through unknown agentName|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.ts ×1 · 2 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×1 · 4 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×1 · 2 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×1 · 3 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×3 · 4 introduced LOCrunSubagentTool.ts ×3runSubagentTool.ts ×3 · 5 introduced LOCrunSubagentTool.ts ×3runSubagentTool.ts ×3 · 7 introduced LOCrunSubagentTool.ts ×3runSubagentTool.ts ×1 · 1 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×3 · 26 introduced LOCrunSubagentTool.ts ×3runSubagentTool.ts ×2 · 4 introduced LOCrunSubagentTool.ts ×2runSubagentTool.ts ×4 · 12 introduced LOCrunSubagentTool.ts ×4runSubagentTool.ts ×1 · 38 introduced LOCrunSubagentTool.ts ×1runSubagentTool.ts ×1 · 12 introduced LOCrunSubagentTool.ts ×1runSubagentTool.test|title=RunSubagentTool resultText trimming trims leading empty codeblocks (```\n```) from result|occurrence=1 · 0 introduced LOCrunSubagentTool.test|tit…runSubagentTool.ts ×11 · 125 introduced LOCrunSubagentTool.ts ×11chatSelectedModel.ts ×3 · 12 introduced LOCchatSelectedModel.ts ×3chatSelectedModel.test|title=ChatSelectedModel preserves a retired explicit profile selection|occurrence=1 · 0 introduced LOCchatSelectedModel.test|t…chatSelectedModel.test|title=ChatSelectedModel stores shared and targeted selections in profile user storage|occurrence=1 · 0 introduced LOCchatSelectedModel.test|t…chatSelectedModel.ts ×1 · 3 introduced LOCchatSelectedModel.ts ×1chatSelectedModel.ts ×1 · 2 introduced LOCchatSelectedModel.ts ×1chatSelectedModel.ts ×2 · 9 introduced LOCchatSelectedModel.ts ×2chatSelectedModel.ts ×2 · 5 introduced LOCchatSelectedModel.ts ×2chatSelectedModel.ts ×2 · 9 introduced LOCchatSelectedModel.ts ×2chatSelectedModel.ts ×9 · 106 introduced LOCchatSelectedModel.ts ×9chatSelectedModel.test|title=ChatSelectedModel drops a retired automatic profile selection|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/chatSelectedModel.test|title=ChatSelectedModel drops a retired automatic profile selection|occurrence=1chatSelectedModel.test|t…chatSelectedModel.test|title=ChatSelectedModel migrates the application-scoped selection to profile user storage|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/chatSelectedModel.test|title=ChatSelectedModel migrates the application-scoped selection to profile user storage|occurrence=1chatSelectedModel.test|t…chatSelectedModel.test|title=ChatSelectedModel preserves a retired explicit profile selection|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/chatSelectedModel.test|title=ChatSelectedModel preserves a retired explicit profile selection|occurrence=1chatSelectedModel.test|t…chatSelectedModel.test|title=ChatSelectedModel stores shared and targeted selections in profile user storage|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/chatSelectedModel.test|title=ChatSelectedModel stores shared and targeted selections in profile user storage|occurrence=1chatSelectedModel.test|t…runSubagentTool.test|title=RunSubagentTool explicit model parameter explicit model overrides agent configured model|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool explicit model parameter explicit model overrides agent configured model|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool explicit model parameter model property is included in tool schema without enum|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool explicit model parameter model property is included in tool schema without enum|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool explicit model parameter resolves explicit model parameter without agentName|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool explicit model parameter resolves explicit model parameter without agentName|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error when explicit model has higher multiplier|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error when explicit model has higher multiplier|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error with available models when explicit model is not found|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error with available models when explicit model is not found|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error with no models message when no models are available|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool explicit model parameter throws error with no models message when no models are available|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool getToolData returns basic tool data|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool getToolData returns basic tool data|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior honors a user-authored agent's explicit Copilot model even when main model is BYOK|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior honors a user-authored agent's explicit Copilot model even when main model is BYOK|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior skips Copilot fallback but uses a non-Copilot fallback when main model is BYOK|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior skips Copilot fallback but uses a non-Copilot fallback when main model is BYOK|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior skips Copilot fallback models when main model is BYOK and inherits the main model|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior skips Copilot fallback models when main model is BYOK and inherits the main model|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior throws error when subagent model has higher multiplier|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior throws error when subagent model has higher multiplier|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses main model when no subagent is specified|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses main model when no subagent is specified|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses main model when subagent has no model configured|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses main model when subagent has no model configured|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when it has equal multiplier|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when it has equal multiplier|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when it has lower multiplier|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when it has lower multiplier|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when main model has no multiplier|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when main model has no multiplier|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when subagent model has no multiplier|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses subagent model when subagent model has no multiplier|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses the Copilot fallback model when no main model is set|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses the Copilot fallback model when no main model is set|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool model fallback behavior uses the Copilot fallback model when the main model is also Copilot|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool model fallback behavior uses the Copilot fallback model when the main model is also Copilot|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking depth is decremented after invoke completes|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking depth is decremented after invoke completes|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking disables runSubagent tool when depth reaches hard limit|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking disables runSubagent tool when depth reaches hard limit|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking disables runSubagent tool when nesting is disabled|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking disables runSubagent tool when nesting is disabled|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking enables runSubagent tool at depth 0 when nesting is enabled|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking enables runSubagent tool at depth 0 when nesting is enabled|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking inherits the current agent instructions when agentName is omitted|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool nested subagent depth tracking inherits the current agent instructions when agentName is omitted|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool onDidInvokeTool event events with different subagentInvocationId are distinguishable|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool onDidInvokeTool event events with different subagentInvocationId are distinguishable|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool onDidInvokeTool event mock service fires onDidInvokeTool events with correct data|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool onDidInvokeTool event mock service fires onDidInvokeTool events with correct data|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool prepareToolInvocation passes through unknown agentName|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool prepareToolInvocation passes through unknown agentName|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool prepareToolInvocation returns correct toolSpecificData|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool prepareToolInvocation returns correct toolSpecificData|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool resultText trimming trims leading empty codeblocks (```\n```) from result|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool resultText trimming trims leading empty codeblocks (```\n```) from result|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool subagent credits leaves credits unset when no usage is reported|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool subagent credits leaves credits unset when no usage is reported|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool subagent credits records credits when the subagent fails after reporting usage|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool subagent credits records credits when the subagent fails after reporting usage|occurrence=1runSubagentTool.test|tit…runSubagentTool.test|title=RunSubagentTool subagent credits writes the running credit total onto the subagent toolSpecificData|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test|title=RunSubagentTool subagent credits writes the running credit total onto the subagent toolSpecificData|occurrence=1runSubagentTool.test|tit…Focused file · src/vs/workbench/contrib/chat/common/chatSelectedModel.ts · 241 LOCcommon/chatSelectedModel…

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 > /*--------------------------------------------------------------------------------------------- chatSelectedModel.ts ×9
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
7 > import { IStorageService, StorageScope, StorageTarget } from '../../../../platform/storage/common/storage.js';
8 > import { ChatContextKeys } from './actions/chatContextKeys.js';
9 > import { COPILOT_VENDOR_ID, ILanguageModelChatMetadata, ILanguageModelsService } from './languageModels.js';
10 >
11 > /**
12 > * Storage key prefix for persisted model selections.
13 > * Full key format: `chat.currentLanguageModel.{location}[.{modelTarget}]`
14 > */
15 > export const SELECTED_MODEL_STORAGE_KEY_PREFIX = 'chat.currentLanguageModel.';
16 >
17 > export const SELECTED_MODEL_STORAGE_SCOPE = StorageScope.PROFILE;
18 > export const SELECTED_MODEL_STORAGE_TARGET = StorageTarget.USER;
19 >
20 > /**
21 > * Builds the storage key used to persist the selected language model for a
22 > * given chat location and optional model target.
23 > *
24 > * Shared by model-selection surfaces so they can read and write the explicit
25 > * remembered preference without depending on widget internals.
26 > */
27 > export function getSelectedModelStorageKey(location: string, modelTarget?: string): string {
28 > if (modelTarget) { chatSelectedModel.ts ×2
29 > return `${SELECTED_MODEL_STORAGE_KEY_PREFIX}${location}.${modelTarget}`; chatSelectedModel.ts ×2
30 > }
31 > return `${SELECTED_MODEL_STORAGE_KEY_PREFIX}${location}`; chatSelectedModel.ts ×2
32 > }
34 > export function storeSelectedModel(
35 > storageService: IStorageService, chatSelectedModel.ts ×2
36 > location: string,
37 > modelTarget: string | undefined,
38 > identifier: string,
39 > ): void {
40 > storageService.store(getSelectedModelStorageKey(location, modelTarget), identifier, SELECTED_MODEL_STORAGE_SCOPE, SELECTED_MODEL_STORAGE_TARGET);
41 > }
43 > /** Reads the selected model and lazily migrates the previous application-scoped value. */
44 > export function getStoredSelectedModel(
45 > storageService: IStorageService, chatSelectedModel.ts ×2
46 > location: string,
47 > modelTarget?: string,
48 > ): string | undefined {
49 > const key = getSelectedModelStorageKey(location, modelTarget);
50 > const isDefaultKey = `${key}.isDefault`;
51 > const identifier = storageService.get(key, SELECTED_MODEL_STORAGE_SCOPE);
52 > if (identifier) {
53 > const wasAutomaticDefault = storageService.getBoolean(isDefaultKey, SELECTED_MODEL_STORAGE_SCOPE); chatSelectedModel.ts ×2
54 > storageService.remove(isDefaultKey, SELECTED_MODEL_STORAGE_SCOPE);
55 > if (wasAutomaticDefault) {
56 > storageService.remove(key, SELECTED_MODEL_STORAGE_SCOPE); chatSelectedModel.ts ×1
57 > return undefined;
58 > }
59 > return identifier; chatSelectedModel.ts ×1
60 > }
62 > const legacyIdentifier = storageService.get(key, StorageScope.APPLICATION);
63 > if (!legacyIdentifier) {
64 return undefined;
65 }
67 > const wasAutomaticDefault = storageService.getBoolean(isDefaultKey, StorageScope.APPLICATION, true);
68 > storageService.remove(key, StorageScope.APPLICATION);
69 > storageService.remove(isDefaultKey, StorageScope.APPLICATION);
70 > if (wasAutomaticDefault) {
71 return undefined;
72 }
74 > storeSelectedModel(storageService, location, modelTarget, legacyIdentifier);
75 > return legacyIdentifier;
76 > }
78 > /**
79 > * Resolves the currently selected chat model identifier using a two-step
80 > * strategy:
81 > *
82 > * 1. Read the `chatModelId` context key (set when a chat widget is active).
83 > * 2. Fall back to the persisted explicit model preference.
84 > *
85 > * Returns the raw model identifier string (may include a vendor prefix like
86 > * `"copilot/gpt-4.1"` from storage, or a short id like `"gpt-4.1"` from
87 > * the context key), or `undefined` if no selection is available.
88 > */
89 > export function getSelectedModelIdentifier(
90 contextKeyService: IContextKeyService,
91 storageService: IStorageService,
92 ): string | undefined {
93 // Step 1: Context key (live, widget-scoped)
94 const contextKeyModelId = contextKeyService.getContextKeyValue<string>(ChatContextKeys.chatModelId.key);
95 if (contextKeyModelId) {
96 return contextKeyModelId;
97 }
98
99 // Step 2: Persisted explicit preference (survives reload)
100 return getPersistedSelectedModelIdentifier(contextKeyService, storageService);
101 }
103 > /**
104 > * Reads the persisted, fully-qualified model identifier written by a model
105 > * selection surface (e.g. `"copilot/gpt-4.1"` or `"customendpoint/ANT/gpt-4.1"`).
106 > *
107 > * Unlike the `chatModelId` context key (which holds only the short, lower-cased
108 > * model id), the persisted identifier carries the vendor and therefore
109 > * disambiguates the same model served via BYOK vs CAPI. Returns `undefined`
110 > * when no selection has been persisted.
111 > */
112 > export function getPersistedSelectedModelIdentifier(
113 contextKeyService: IContextKeyService,
114 storageService: IStorageService,
115 ): string | undefined {
116 const location = contextKeyService.getContextKeyValue<string>(ChatContextKeys.location.key) ?? 'panel';
117 const sessionType = contextKeyService.getContextKeyValue<string>(ChatContextKeys.chatSessionType.key) ?? '';
118 const candidateKeys = sessionType
119 ? [sessionType, undefined]
120 : [undefined];
121
122 for (const modelTarget of candidateKeys) {
123 const persisted = getStoredSelectedModel(storageService, location, modelTarget);
124 if (persisted) {
125 return persisted;
126 }
127 }
128
129 return undefined;
130 }
132 > /**
133 > * Resolves the registered metadata of the currently selected chat model.
134 > *
135 > * The selected identifier may be a fully-qualified id (e.g. `"copilot/gpt-4.1"`
136 > * from persisted storage) or a short, lower-cased model id (e.g. `"gpt-4.1"`
137 > * from the `chatModelId` context key, which is set to `metadata.id`). The short
138 > * id cannot disambiguate the same model served via BYOK vs CAPI, so when a
139 > * direct registry lookup fails we fall back to the persisted, fully-qualified
140 > * identifier (which carries the vendor) rather than matching on the short id.
141 > *
142 > * Returns `undefined` when no model is selected or the selection cannot be
143 > * resolved to a registered model (e.g. the provider has not been activated
144 > * yet); callers that only need the vendor can fall back to
145 > * {@link getSelectedModelVendor}.
146 > */
147 > export function getSelectedModelMetadata(
148 contextKeyService: IContextKeyService,
149 storageService: IStorageService,
150 languageModelsService: ILanguageModelsService,
151 ): ILanguageModelChatMetadata | undefined {
152 const modelId = getSelectedModelIdentifier(contextKeyService, storageService);
153 if (!modelId) {
154 return undefined;
155 }
156
157 // Direct registry lookup (handles fully-qualified identifiers).
158 const direct = languageModelsService.lookupLanguageModel(modelId);
159 if (direct) {
160 return direct;
161 }
162
163 // The selected id was likely the short, lower-cased model id from the
164 // `chatModelId` context key, which cannot distinguish a BYOK-served model
165 // from the same model served via CAPI. Fall back to the persisted,
166 // fully-qualified identifier which carries the vendor.
167 const persistedId = getPersistedSelectedModelIdentifier(contextKeyService, storageService);
168 if (persistedId && persistedId !== modelId) {
169 return languageModelsService.lookupLanguageModel(persistedId);
170 }
171
172 return undefined;
173 }
175 > /**
176 > * Resolves the vendor of the currently selected chat model.
177 > *
178 > * Tries the language model registry first (authoritative when models are
179 > * registered), then falls back to extracting the vendor prefix from the
180 > * persisted model identifier (e.g. `"copilot/gpt-4.1"` → `"copilot"`).
181 > *
182 > * Returns `undefined` if no model selection is available.
183 > */
184 > export function getSelectedModelVendor(
185 contextKeyService: IContextKeyService,
186 storageService: IStorageService,
187 languageModelsService: ILanguageModelsService,
188 ): string | undefined {
189 const metadata = getSelectedModelMetadata(contextKeyService, storageService, languageModelsService);
190 if (metadata) {
191 return metadata.vendor;
192 }
193
194 // Fall back to vendor prefix from the persisted identifier
195 // (e.g. "copilot/gpt-4.1" or "customendpoint/ANT/claude-sonnet-4-6")
196 const modelId = getSelectedModelIdentifier(contextKeyService, storageService);
197 if (modelId?.includes('/')) {
198 return modelId.split('/')[0];
199 }
200
201 return undefined;
202 }
204 > /**
205 > * Returns whether the given model is a "bring your own key" (BYOK) model.
206 > *
207 > * BYOK models are served using user-supplied credentials and are flagged as
208 > * such by their provider via {@link ILanguageModelChatMetadata.isBYOK}. All
209 > * other models (built-in Copilot, Copilot/Claude CLI, and agent-host models)
210 > * are served through the Copilot (CAPI) service and are therefore not BYOK.
211 > */
212 > export function isByokModel(metadata: ILanguageModelChatMetadata): boolean {
213 > return metadata.isBYOK === true; chatSelectedModel.ts ×1
214 > }
216 > /**
217 > * Returns whether the currently selected chat model is a Copilot model
218 > * (i.e. not BYOK).
219 > *
220 > * When the selection resolves to registered metadata this is the inverse of
221 > * {@link isByokModel}, so agent-host (CAPI-backed) models count as Copilot.
222 > * When no model is selected yet (widget not initialized) this returns `true`
223 > * so quota-style surfaces treat the unknown case as Copilot. As a last
224 > * resort, an unregistered selection is classified by its vendor prefix.
225 > */
226 > export function isSelectedModelCopilot(
227 contextKeyService: IContextKeyService,
228 storageService: IStorageService,
229 languageModelsService: ILanguageModelsService,
230 ): boolean {
231 const metadata = getSelectedModelMetadata(contextKeyService, storageService, languageModelsService);
232 if (metadata) {
233 return !isByokModel(metadata);
234 }
235
236 const vendor = getSelectedModelVendor(contextKeyService, storageService, languageModelsService);
237 if (!vendor) {
238 return true; // no selection → treat as Copilot
239 }
240 return vendor === COPILOT_VENDOR_ID;
241 }