Skip to content

Implements #309540#311061

Open
hediet wants to merge 2 commits intomainfrom
hediet/b/fine-rook
Open

Implements #309540#311061
hediet wants to merge 2 commits intomainfrom
hediet/b/fine-rook

Conversation

@hediet
Copy link
Copy Markdown
Member

@hediet hediet commented Apr 17, 2026

Implements #309540

hediet added 2 commits April 17, 2026 20:28
Instead of hard-blocking subagent models that exceed the main model's
cost tier, show a confirmation dialog with "Allow" / "Use Current Model"
buttons. If the user approves, the expensive model is used; otherwise
the subagent falls back to the parent model.

- resolveSubagentModel returns exceedsCostTier info instead of throwing
- prepareToolInvocation surfaces confirmationMessages with customButtons
- invoke checks selectedCustomButton to apply or fall back
- chatListRenderer skips subagent grouping while parent tool awaits confirmation
Copilot AI review requested due to automatic review settings April 17, 2026 18:30
@hediet hediet self-assigned this Apr 17, 2026
@hediet hediet added this to the 1.118.0 milestone Apr 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 960abe89 Current: cc08cba8

Changed (5)

chat/aiCustomizations/aiCustomizationManagementEditor/McpBrowseMode/Light
Before After
before after
editor/inlineChatAffordance/InlineChatOverlay/Light
Before After
before after
editor/inlineCompletions/other/JumpToHint/Dark
Before After
before after
agentSessionsViewer/WithDiffChanges/Dark
Before After
before after
agentSessionsViewer/WithDiffChanges/Light
Before After
before after

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

Enables subagent invocations to request a model that exceeds the current session model’s cost tier by returning a confirmation prompt (rather than hard-blocking), and updates rendering/tests to support the new confirmation flow.

Changes:

  • Update RunSubagentTool model resolution to return confirmation messages when the selected subagent model exceeds the current cost tier, and apply the user’s choice during invoke.
  • Adjust chat list rendering so parent subagent tool invocations that are waiting for confirmation render as a regular tool invocation (so confirmation buttons are visible).
  • Update/add unit tests to cover the new prepare/invoke confirmation behavior.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test.ts Updates existing tests from “throws” to “confirmation returned” and adds invoke-path tests for Allow vs fallback behavior.
src/vs/workbench/contrib/chat/common/tools/builtinTools/runSubagentTool.ts Implements expensive-model confirmation via confirmationMessages, caches resolution between prepare/invoke, and applies user choice during invoke.
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Ensures parent subagent tool invocations waiting for confirmation are not grouped, allowing confirmation UI to display.

Copilot's findings

Comments suppressed due to low confidence (1)

src/vs/workbench/contrib/chat/test/common/tools/builtinTools/runSubagentTool.test.ts:1146

  • This test hardcodes the custom-button label ('Use Current Model') into selectedCustomButton. Since the production label is localized and may change, consider sourcing it from the same localization key used by RunSubagentTool so the test stays aligned with the UI string.
				modelId: 'main-model-id',
				selectedCustomButton: 'Use Current Model',
			} as IToolInvocation, async () => 0, { report() { } }, CancellationToken.None);
  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment on lines +433 to +437
private applyResolvedModel(resolved: IResolvedSubagentModel, invocation: IToolInvocation, apply: (result: { modeModelId: string | undefined; resolvedModelName: string | undefined }) => void): void {
if (resolved.exceedsCostTier && invocation.selectedCustomButton !== localize('subagent.expensiveModel.allow', "Allow")) {
// User chose "Use Current Model" or didn't approve — fall back to the main model
const fallback = resolved.exceedsCostTier;
apply({ modeModelId: fallback.fallbackModelId, resolvedModelName: fallback.fallbackModelName });
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

applyResolvedModel decides approval by comparing invocation.selectedCustomButton to a freshly-localized "Allow" string. This is tightly coupled to the button label and can silently break if the label/translation changes (comparison logic and customButtons would drift). Consider deriving the comparison value from the same source as the buttons (e.g. reuse a shared constant for the allow label, or persist the allow-button label/id in the cached resolved-model data) so prepare/invoke stay consistent.

Copilot uses AI. Check for mistakes.
message: localize(
'subagent.expensiveModel.message',
"The subagent requests '{0}' ({1}x premium) which exceeds the current model's cost tier ({2}x). Allow the expensive model, or continue with '{3}'?",
modelName, modelMultiplier, mainMultiplier, fallbackModelName ?? 'current model'
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

The confirmation message inserts the fallback label via fallbackModelName ?? 'current model'. Since this string can be shown to the user, it should be localized as well (or moved into the localized message template) to avoid leaking an English-only fragment in non-English locales.

Suggested change
modelName, modelMultiplier, mainMultiplier, fallbackModelName ?? 'current model'
modelName,
modelMultiplier,
mainMultiplier,
fallbackModelName ?? localize('subagent.expensiveModel.currentModel', "current model")

Copilot uses AI. Check for mistakes.
Comment on lines +1106 to +1108
modelId: 'main-model-id',
selectedCustomButton: 'Allow',
} as IToolInvocation, async () => 0, { report() { } }, CancellationToken.None);
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

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

This test hardcodes the custom-button label ('Allow') into selectedCustomButton. Since the production label is localized and may change, consider sourcing it from the same localization key used by RunSubagentTool so the test stays aligned with the UI string.

This issue also appears on line 1144 of the same file.

Copilot uses AI. Check for mistakes.
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.

3 participants