Skip to content

Add optional model parameter to runSubagent tool#308784

Merged
hediet merged 2 commits intomainfrom
hediet/b/equivalent-porpoise
Apr 9, 2026
Merged

Add optional model parameter to runSubagent tool#308784
hediet merged 2 commits intomainfrom
hediet/b/equivalent-porpoise

Conversation

@hediet
Copy link
Copy Markdown
Member

@hediet hediet commented Apr 9, 2026

Fixes #298380
Deprecates #298161

When the parent model guesses the model name wrong, the error lists all available models:

Code_-_OSS_1f1vkQsJDK

Copilot AI review requested due to automatic review settings April 9, 2026 13:49
@hediet hediet enabled auto-merge (rebase) April 9, 2026 13:49
@hediet hediet self-assigned this Apr 9, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 runSubagent tool 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

  • prepareToolInvocation resolves args.model regardless of whether SubagentToolCustomAgents is enabled. If this setting is meant to gate the feature, consider ignoring args.model (treat as undefined) unless customAgentsEnabled is 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

@hediet hediet merged commit b947d0b into main Apr 9, 2026
37 of 38 checks passed
@hediet hediet deleted the hediet/b/equivalent-porpoise branch April 9, 2026 15:40
@vs-code-engineering vs-code-engineering Bot added this to the 1.116.0 milestone Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow runSubagent tool to specify a language model

3 participants