Fix context size handling for Agent Host#322470
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes context size handling for Agent Host-backed chat models by representing the selected context window as a first-class ModelSelection.maxContextWindow value (token count) rather than smuggling it through the string-only config bag. It also introduces recommendedContextWindows on models so the chat UI can present a context-size picker consistently across agents, while letting each agent map the numeric selection to its backend representation (e.g. Copilot SDK contextTier).
Changes:
- Add
recommendedContextWindowsto model info andmaxContextWindowto model selection in the agent-host protocol types, and plumb the new fields through side effects. - Synthesize a tokens-group “Context Size” picker from
recommendedContextWindows, and lift the selected numeric value intoModelSelection.maxContextWindowwhen creating sessions. - Update Copilot agent/session launching to resolve SDK
contextTierfrom the selected context window, and adjust tests accordingly.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts | Adds coverage for lifting context size into maxContextWindow and for synthesizing the picker from recommendedContextWindows. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Lifts tokens-group numeric config values into ModelSelection.maxContextWindow and includes it in selection equality checks. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostLanguageModelProvider.ts | Synthesizes a “Context Size” configuration property from recommendedContextWindows. |
| src/vs/platform/agentHost/test/node/copilotAgent.test.ts | Updates model schema expectations and adds a materialization test for mapping selected context window → SDK tier. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Updates model fixtures to include recommendedContextWindows. |
| src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts | Moves contextTier derivation into the agent and threads it through launch plans. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Exposes recommendedContextWindows, accepts maxContextWindow on selections, and resolves SDK contextTier robustly. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Plumbs recommendedContextWindows into side-effect output. |
| src/vs/platform/agentHost/common/state/protocol/channels-root/state.ts | Extends protocol state types with recommendedContextWindows and ModelSelection.maxContextWindow. |
| src/vs/platform/agentHost/common/agentService.ts | Extends IAgentModelInfo with recommendedContextWindows. |
Copilot's findings
- Files reviewed: 10/10 changed files
- Comments generated: 3
roblourens
reviewed
Jun 23, 2026
pwang347
commented
Jun 23, 2026
pwang347
commented
Jun 23, 2026
sandy081
previously approved these changes
Jun 23, 2026
roblourens
approved these changes
Jun 24, 2026
roblourens
previously approved these changes
Jun 24, 2026
lramos15
approved these changes
Jun 24, 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 #321707
Notes:
Dependent on AHP changes: