Skip to content

Prototype: Auto Model Routing collapsible card in chat (dev command)#311442

Draft
Copilot wants to merge 10 commits intomainfrom
copilot/add-auto-model-routing-prototype
Draft

Prototype: Auto Model Routing collapsible card in chat (dev command)#311442
Copilot wants to merge 10 commits intomainfrom
copilot/add-auto-model-routing-prototype

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 20, 2026

Prototypes a "Copilot Auto Model Selection Routing" card that reuses the existing collapsible content-part styling (tool calls / thinking / file changes) to preview how an intelligently-selected model in auto mode would surface in chat. Gated behind a Developer command — no real router is wired up.

Description

  • New content kind autoModelRouting (IChatAutoModelRoutingPart) added to IChatProgress and IChatProgressHistoryResponseContent. Carries: selectedModel, selectionReason, intent, confidence, predictedLatencyMs, costTier, candidates[]. Switch arms added in partsToRepr (ignore) and chatSessionOperationLog (static).
  • Renderer ChatAutoModelRoutingContentPart extends ChatCollapsibleContentPart. Collapsed: Routed to <model> with a sparkle icon. Expanded view (revised after design feedback):
    • Header row with the title plus an intent "chip"
    • One-line selection reason in descriptionForeground
    • Small badge-style chips for confidence, predicted latency, and cost tier (using --vscode-badge-background)
    • A unified ranked candidate list with grey horizontal bar graphs scaled to the top score; the selected model is highlighted with a check icon, bold name, an accented progressBar-background bar, and a subtle hover-background row treatment. Other candidates use muted grey bars (scrollbarSlider-background)
    • Each candidate row uses a single left-hand column that stacks the model name with a muted subtitle for its reason; the bar and score are vertically centered against that column on the right (no more two-column italic reason spanning under the bar)
    • All colors come from VS Code theme tokens so it adapts to light/dark/high-contrast themes
  • Dispatched from chatListRenderer.renderChatContentPart.
  • Dev command Developer: Simulate Auto Model Selection Routing (Prototype) injects a sample part into the focused chat via IChatService.addCompleteRequest, sandwiched between two markdown lines:
const message: IChatProgress[] = [
    { kind: 'markdownContent', content: new MarkdownString('Routing your request through Copilot Auto…') },
    {
        kind: 'autoModelRouting',
        selectedModel: 'GPT-5',
        selectionReason: 'Best fit for multi-file refactoring with strong code reasoning',
        intent: 'Code edit (multi-file refactor)',
        confidence: 0.86,
        predictedLatencyMs: 4200,
        costTier: 'medium',
        candidates: [
            { modelName: 'Claude Sonnet 4.5', score: 0.81, reason: 'Strong reasoning, slightly higher latency' },
            { modelName: 'GPT-4.1',           score: 0.74, reason: 'Lower cost, weaker on large refactors' },
            { modelName: 'o3-mini',           score: 0.62, reason: 'Fast, but limited code-edit accuracy' },
        ],
    },
    { kind: 'markdownContent', content: new MarkdownString('Done — using **GPT-5** for this turn.') },
];

Static preview of the collapsed and expanded states (dark theme):

How to test

  1. Run a dev build, open a chat.
  2. Command Palette → Developer: Simulate Auto Model Selection Routing (Prototype).
  3. Verify the collapsed card reads Routed to GPT-5 with a sparkle icon.
  4. Expand the card and verify the header + intent chip, the metadata chips (Confidence / latency / Cost), and the ranked candidate list with grey bar graphs render — with GPT-5 highlighted as the selected model and each candidate's reason shown as a muted subtitle directly beneath its name.
Original prompt

you know how we show this cool expandable thing for tool calls and thinking and file changes and stuff. i want to see what it would look like to apply this same styling to this new concept for auto model routing in vscode, where there is an intelligently sepected model in auto instead of how its selected today. I'd love to somehow prototpye this within a vscode chat, wher i can trigger a command and somehow see this rendered in the chat UI? with the info in the black screenshot, but rendered as we would in vscode, similar to the white screenshot when it's not expanded. This is jsut a test to seee how it would work, so it can be behind a dev command. use vscode styling but show the info in the black screenshot that says copilot auto model selection routing

The user has attached the following file paths as relevant context:

  • .github/copilot-instructions.md
  • AGENTS.md

Created from VS Code.

Copilot AI requested review from Copilot and removed request for Copilot April 20, 2026 18:36
Copilot AI requested review from Copilot and removed request for Copilot April 20, 2026 18:44
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/43632c6f-4ef0-4342-a39f-755e5c941185

Co-authored-by: eli-w-king <201316543+eli-w-king@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 20, 2026 18:45
Copilot AI changed the title [WIP] Add prototype for auto model routing in VSCode chat Prototype: Auto Model Routing collapsible card in chat (dev command) Apr 20, 2026
Copilot AI requested a review from eli-w-king April 20, 2026 18:46
@eli-w-king
Copy link
Copy Markdown
Contributor

@copilot this doesn't look great but it works as expected. can we make it look a bit more like the origional desgin but more vscode. the image with the colors is the ogigional design. we can include grey bar graphs maybe? idk

Copilot AI requested review from Copilot and removed request for Copilot April 20, 2026 18:57
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot this doesn't look great but it works as expected. can we make it look a bit more like the origional desgin but more vscode. the image with the colors is the ogigional design. we can include g...

Reworked the expanded view in 699a7be — header + intent chip, a one‑line reason, small chips for confidence/latency/cost, and a unified ranked list with grey horizontal bar graphs (selected model highlighted with a check + accent bar, other candidates in muted grey). All colors come from VS Code theme tokens (badge-background, scrollbarSlider-background, progressBar-background, list-hoverBackground, charts-green) so it adapts to any theme.

Static preview of the new look (dark theme):

Auto model routing card preview

@eli-w-king
Copy link
Copy Markdown
Contributor

@copilot also the two column reason styling could be better.

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/ee62e087-8ae4-4a20-a525-626fe241160e

Co-authored-by: eli-w-king <201316543+eli-w-king@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot April 20, 2026 19:04
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 20, 2026

@copilot also the two column reason styling could be better.

Restructured the candidate row in c501642 — the reason is no longer a second row spanning under the bar/score columns. It now sits as a muted subtitle directly under the model name in a single left-hand column, with the bar and score aligned vertically on the right. Italic styling dropped.

Candidate row v2

Copilot AI review requested due to automatic review settings April 20, 2026 21:21
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 a prototype “Auto Model Routing” collapsible chat content part (behind a Developer command) to preview how an auto model selection decision could be surfaced in the VS Code chat UI.

Changes:

  • Introduces new progress/content kind autoModelRouting (IChatAutoModelRoutingPart) and threads it through chat model/history/serialization handling.
  • Adds a new ChatAutoModelRoutingContentPart renderer and wires it into chatListRenderer.
  • Adds a Developer command to inject a sample routing card into the focused chat session.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/common/model/chatSessionOperationLog.ts Treats autoModelRouting as a static response-part kind for mutation logging.
src/vs/workbench/contrib/chat/common/model/chatModel.ts Adds IChatAutoModelRoutingPart to history content union and ignores it in partsToRepr.
src/vs/workbench/contrib/chat/common/chatService/chatService.ts Defines IChatAutoModelRoutingPart + related types; adds to IChatProgress.
src/vs/workbench/contrib/chat/browser/widget/chatListRenderer.ts Dispatches autoModelRouting to a new content-part renderer.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/media/chatAutoModelRoutingContentPart.css Styles for the new routing collapsible card.
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatAutoModelRoutingContentPart.ts Implements the collapsible routing card renderer.
src/vs/workbench/contrib/chat/browser/actions/chatDeveloperActions.ts Adds a Developer command that injects a sample autoModelRouting part into chat.

Copilot's findings

Comments suppressed due to low confidence (2)

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatAutoModelRoutingContentPart.ts:94

  • hasSameContent only compares candidate modelNames and ignores score/reason. If the routing details update (e.g. scores change or reasons change), this method can incorrectly return true and prevent the UI from re-rendering. Include the relevant candidate fields in the equality check (or use a shallow/deep compare of the candidate objects).
		const a = this.routingPart.candidates ?? [];
		const b = other.candidates ?? [];
		if (a.length !== b.length) {
			return false;
		}
		for (let i = 0; i < a.length; i++) {
			if (a[i].modelName !== b[i].modelName) {
				return false;
			}
		}

src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatAutoModelRoutingContentPart.ts:56

  • The Learn more link opens a new tab/window via target="_blank" but doesn’t set rel="noopener noreferrer". This allows the opened page to access window.opener and can be a security issue. Add the appropriate rel attributes (or avoid target=_blank and route through the opener service).
		const learnMore = $('a.chat-auto-model-routing-learn-more', { href: 'https://aka.ms/copilot-auto-model', target: '_blank' },
			localize('autoModelRouting.learnMore', "Learn more"));
  • Files reviewed: 7/7 changed files
  • Comments generated: 4

Comment on lines 477 to +486
/**
* A progress part representing the execution result of a hook.
* Aligned with the hook output JSON structure: { stopReason, systemMessage, hookSpecificOutput }.
* If {@link stopReason} is set, the hook blocked/denied the operation.
*/
/**
* Prototype: a part describing how the "auto" model selector routed a request
* to a specific underlying language model. Rendered as a collapsible card,
* similar to thinking and tool-call parts.
*/
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

There are two consecutive JSDoc blocks here; the first one (“A progress part representing the execution result of a hook…”) is now detached from IChatHookPart and will no longer document the hook type. Merge/move that comment so it sits immediately above export interface IChatHookPart, and keep only one doc block at this location.

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +72
protected override initContent(): HTMLElement {
const container = $('.chat-auto-model-routing-body');

// Build capability sentence from top 2 capabilities by score
const caps = this.routingPart.capabilities;
let capSentence: string;
if (caps && caps.length >= 2) {
const top = [...caps].sort((a, b) => b.score - a.score).slice(0, 2).map(c => c.name.toLowerCase());
capSentence = localize('autoModelRouting.capSentence', "{0} is selected for high {1} and {2} capability. ",
this.routingPart.selectedModel, top[0], top[1]);
} else if (caps && caps.length === 1) {
capSentence = localize('autoModelRouting.capSentenceSingle', "{0} is selected for high {1} capability. ",
this.routingPart.selectedModel, caps[0].name.toLowerCase());
} else {
capSentence = '';
}

const para = $('.chat-auto-model-routing-footer');
para.appendChild($('span', undefined, capSentence));
para.appendChild($('span', undefined,
localize('autoModelRouting.footer', "Auto routes based on your task and real-time system health and model performance. ")));
const learnMore = $('a.chat-auto-model-routing-learn-more', { href: 'https://aka.ms/copilot-auto-model', target: '_blank' },
localize('autoModelRouting.learnMore', "Learn more"));
para.appendChild(learnMore);
container.appendChild(para);

// Capability score list
if (this.routingPart.capabilities && this.routingPart.capabilities.length > 0) {
container.appendChild($('span.chat-auto-model-routing-section-label', undefined,
localize('autoModelRouting.capabilities', "Task requirements")));
const list = $('ul.chat-auto-model-routing-scores');
for (const cap of this.routingPart.capabilities) {
const li = $('li.chat-auto-model-routing-score-row');
li.appendChild($('span.chat-auto-model-routing-score-name', undefined, cap.name));
li.appendChild($('span.chat-auto-model-routing-score-pct', undefined, `${Math.round(cap.score * 100)}%`));
list.appendChild(li);
}
container.appendChild(list);
}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

IChatAutoModelRoutingPart carries fields like selectionReason, intent, confidence, costTier, and candidates, but the renderer currently only shows a generic footer + capabilities list and never surfaces those fields. This doesn’t match the PR description/UI goals and makes the injected sample data mostly unused; either render the additional fields (reason/intent/metadata/candidate ranking) or trim the part shape/sample to what is actually displayed.

This issue also appears in the following locations of the same file:

  • line 55
  • line 85

Copilot uses AI. Check for mistakes.
Comment on lines +310 to +314
const message: IChatProgress[] = [
{ kind: 'markdownContent', content: new MarkdownString('Routing your request through Copilot Auto…') },
routingPart,
{ kind: 'markdownContent', content: new MarkdownString('Done — using **Claude Opus 4.6** for this turn.') },
];
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

The injected chat markdown strings ("Routing your request through Copilot Auto…", "Done — using …") are user-visible but not localized. Please wrap these in localize(...) (or otherwise externalize them) even though the command is Developer-only, to keep the codebase’s localization guarantees consistent.

Copilot uses AI. Check for mistakes.
Comment on lines +80 to +81
color: var(--vscode-descriptionForeground);
}
Copy link

Copilot AI Apr 20, 2026

Choose a reason for hiding this comment

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

CSS has a stray color: declaration and an extra closing } after .chat-auto-model-routing-score-row, which makes the stylesheet invalid and can cause the remaining rules to be ignored by the CSS parser. Remove the dangling property/brace so subsequent selectors (e.g. -score-name, -score-pct) apply reliably.

Suggested change
color: var(--vscode-descriptionForeground);
}

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