Add optional model parameter to runSubagent tool#308784
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for an optional model input parameter on the runSubagent chat tool so callers (notably custom agents) can request a specific language model for a subagent invocation, with multiplier-based cost fallback to the parent model.
Changes:
- Extend
runSubagenttool input params and model resolution logic to accept an explicit model override. - Add runtime error messaging that includes available model qualified names when an explicit model can’t be resolved.
- Add unit tests for schema and explicit model-resolution behaviors.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts | Adds model?: string to tool params, updates schema, and implements explicit model resolution + fallback/error behavior. |
| src/vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test.ts | Adds tests for schema exposure and explicit model resolution/fallback/error cases. |
Copilot's findings
Comments suppressed due to low confidence (1)
src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts:507
prepareToolInvocationresolvesargs.modelregardless of whetherSubagentToolCustomAgentsis enabled. If this setting is meant to gate the feature, consider ignoringargs.model(treat as undefined) unlesscustomAgentsEnabledis true, otherwise callers can still force model selection via the parameter even when the feature is disabled.
// Defensive: model may omit agentName despite schema requiring it
const gpEnabled = this.configurationService.getValue<boolean>(ChatConfiguration.GeneralPurposeAgentEnabled);
const customAgentsEnabled = this.configurationService.getValue<boolean>(ChatConfiguration.SubagentToolCustomAgents);
const isGeneralPurpose = gpEnabled && (!args.agentName || args.agentName === GeneralPurposeAgentName);
const subagent = (args.agentName && !isGeneralPurpose && customAgentsEnabled) ? await this.getSubAgentByName(args.agentName) : undefined;
// Resolve the model early and cache it for invoke()
const resolved = this.resolveSubagentModel(subagent, context.modelId, args.model);
this._resolvedModels.set(context.toolCallId, resolved);
- Files reviewed: 2/2 changed files
- Comments generated: 3
…election and update related tests
lszomoru
approved these changes
Apr 9, 2026
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.
Fixes #298380
Deprecates #298161
When the parent model guesses the model name wrong, the error lists all available models: