Skip to content

Model router: display name, context size, and a quieter routing line - #347474

Merged
Bhavya U (bhavyaus) merged 4 commits into
mainfrom
bhavyaus/model-router-display-name-context-size
Nov 10, 2026
Merged

Bhavya U (bhavyaus) merged 4 commits into
mainfrom
bhavyaus/model-router-display-name-context-size

Conversation

@bhavyaus

@bhavyaus Bhavya U (bhavyaus) commented Nov 10, 2026 •

Copy link
Copy Markdown
Collaborator

Additions to model routers (.model-router.yaml, behind chat.copilot.modelRouter.enabled).

Changes

  • display-name. A router file can set the name the model picker shows in place of its file name. The chat's routing line and the router's notices use the same name.
  • context-size: default | long. A route, or the whole router, can ask for a model's larger context window. It applies only to models that offer two sizes; a route that asks for long on a model with one size gets a warning from check_model_router and is left alone. The routing line shows the size the router asked for, such as "1M". The check tool lists each model's context sizes and whether the larger one is billed at a higher rate.
  • A chat on a long window keeps it. The window is read from the chat's routed turns, so it holds when another router picks the next model and after a turn on a model with one size. A model the user picks by hand resets it.
  • No routing line after the first turn of a switching: first-turn router. Such a router routes only the first turn, so later turns no longer show a "stayed on" line, or a "picking a model" row while the turn starts. Routers with switching: auto are unchanged.

How to test

  1. Turn on chat.copilot.modelRouter.enabled and add a router under ~/.agents/model-routers/ with display-name: My Router, and context-size: long on a route whose model offers two context sizes.
  2. Pick the router in an Agent Host Copilot chat. The picker shows "My Router".
  3. Send a message. The routing line reads "My Router picked · 1M" (with the model's own larger size), and the chat's context window is the larger one.
  4. Send a second message. No routing line appears for it.

Bhavya U (bhavyaus) and others added 2 commits November 10, 2026 13:17
A model router file can now set `display-name`, which the model picker and the chat's routing line show in place of the file name. Router notices use the same label.

A route, or the whole router, can set `context-size: default | long`. `long` runs a model on its larger context window when it offers one, and a chat that is on a long window keeps one. The routing line shows the size the router asked for, such as "1M". The check tool lists each model's context sizes and whether the larger one is billed at a higher rate.

A router with `switching: first-turn` routes only a chat's first turn. Later turns no longer show a "stayed on" line, or a "picking a model" line while the turn starts.

Co-authored-by: Copilot <[email protected]>
… pending routing row

A chat that a router put on a long context window now keeps it when another router picks the next model, and after a turn on a model that has only one context size. The window is read from the chat's routed turns instead of from the latest pick alone; a model the user picks by hand still resets it.

A "picking a model" row that is already showing now settles when a first-turn router keeps the chat's pick. Before, the kept pick was dropped and the row stayed until the response ended, which happened for chats whose last pick predates the first-turn-only flag or whose router was changed to `switching: first-turn`.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 10, 2026 21:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved routing and pricing defects can hide fresh model-selection progress, unexpectedly shrink chat context windows, and misreport cheaper long-context pricing as more expensive.

3 open issues
What changed in this PR

Extends experimental YAML model routers for Agent Host Copilot chats with clearer names, context-window controls, and quieter routing feedback.

Changes:

  • Adds display-name and router-level or per-route context-size options.
  • Carries context choices through routing history and displays requested sizes in chat.
  • Suppresses repeated first-turn routing rows and adds parser, routing, tool, and accessibility coverage.
File Description
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​stateToProgressAdapter.test.ts Tests settled first-turn router detection.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​agentSessions/​agentHostChatContribution.test.ts Tests pending-row settlement for retained picks.
src/​vs/​workbench/​contrib/​chat/​test/​browser/​accessibility/​chatResponseAccessibleView.test.ts Tests accessible context-size descriptions.
src/​vs/​workbench/​contrib/​chat/​common/​chatService/​chatService.ts Adds context size to routing UI data.
src/​vs/​workbench/​contrib/​chat/​common/​chatAutoModeExplainability.ts Formats context sizes in routing text.
src/​vs/​workbench/​contrib/​chat/​browser/​widget/​chatContentParts/​chatAutoModeResolutionContentPart.ts Detects context-size changes when rendering.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​stateToProgressAdapter.ts Adds settled-pick detection and pending-row support.
src/​vs/​workbench/​contrib/​chat/​browser/​agentSessions/​agentHost/​agentHostSessionHandler.ts Applies labels, context sizes, and routing-row suppression.
src/​vs/​platform/​agentHost/​test/​node/​copilotModelRouterTools.test.ts Tests context-size and pricing output.
src/​vs/​platform/​agentHost/​test/​node/​copilotModelRouter.test.ts Tests display names and long-window continuity.
src/​vs/​platform/​agentHost/​test/​common/​modelRouter.test.ts Tests new YAML fields and context-size validation.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotModelRouterTools.ts Reports context choices and long-context pricing indicators.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotModelRouter.ts Applies context choices and records routing metadata.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotBuiltinSkills.ts Documents the new router options.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgent.ts Uses router display names in the model picker.
src/​vs/​platform/​agentHost/​common/​state/​sessionState.ts Extends routing metadata with labels and context choices.
src/​vs/​platform/​agentHost/​common/​modelRouter.ts Parses and resolves display names and context sizes.
src/​vs/​platform/​agentHost/​common/​meta/​vscode/​agentUsageMeta.ts Validates and reads the new routing metadata.

Review effort: Balanced

…e routing row

A chat counts as being on a long context window when its model ran on the larger window by default, not only when a route asked for it. The routed info now records that the turn ran on the larger window, separately from the size the router asked for, so a later route with `context-size: default` no longer shrinks such a chat. A route that sets no size on a model that already defaults to the larger window is left without an explicit size.

The check tool reports `longContextCostsMore` only when a long-context price is higher than its standard one. Long-context prices are published whenever they differ, including when they are lower.

The "picking a model" row is no longer hidden after the user picked a model by hand, or selected another router, since the router's pick. The host routes afresh in those cases, and the client now follows the same rule.

Co-authored-by: Copilot <[email protected]>
@bhavyaus
Bhavya U (bhavyaus) requested a balanced review from Copilot November 10, 2026 22:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

After a host restart, a turn sent while the router file is invalid can be mistaken for a manual model choice, causing the next route to shrink a previously selected long context window.

1 open issue
3 resolved since last review

Review effort: Balanced

@bhavyaus
Bhavya U (bhavyaus) enabled auto-merge (squash) November 10, 2026 22:58
@bhavyaus
Bhavya U (bhavyaus) merged commit aadc4c6 into main Nov 10, 2026
53 of 54 checks passed
@bhavyaus
Bhavya U (bhavyaus) deleted the bhavyaus/model-router-display-name-context-size branch November 10, 2026 22:59
@vs-code-engineering vs-code-engineering Bot added this to the 1.147.0 milestone Nov 10, 2026
Bhavya U (bhavyaus) added a commit that referenced this pull request Nov 11, 2026
…routed turn (#347522)

* Model router: keep a long context window across a restart after an unrouted turn

A turn sent on a model router that makes no pick (an invalid or missing
file, no available models, a failed routing call) runs on the chat's
current model. While the host is running, the turn's selection is still
the router, so the chat's long context window and the router's last pick
both hold. After a host restart the provider restores the turn with the
model it ran on as its selection, which read as a model the user picked by
hand: the next routed turn could shrink the window and route afresh.

The turn's usage now records the router it asked for, the same way a
routed turn's usage records the pick, so it is saved with the turn and
restored with it. Reading a chat's long window and its last pick treats
such a turn as a router turn.

Follow-up to a review comment on #347474.

Co-authored-by: Copilot <[email protected]>

* Model router: read an unrouted restored turn's router in the chat too

The chat decides whether a first-turn router's pick is settled the way the
host does. After a restart, a turn that asked for the router and got no
pick has the model it ran on as its selection, so the chat read it as a
model picked by hand and could show a "picking a model" row and a
"stayed on" line for a router that was not picking again. It now reads
the router from the turn's usage, as the host does.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
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.

4 participants