Skip to content

feat(copilotcli): Add auto model configuration#311780

Merged
DonJayamanne merged 8 commits intomainfrom
don/statistical-hornet
Apr 22, 2026
Merged

feat(copilotcli): Add auto model configuration#311780
DonJayamanne merged 8 commits intomainfrom
don/statistical-hornet

Conversation

@DonJayamanne
Copy link
Copy Markdown
Contributor

Co-authored-by: Copilot copilot@github.com

Fixes #311779

Co-authored-by: Copilot <copilot@github.com>
Copilot AI review requested due to automatic review settings April 21, 2026 20:43
@DonJayamanne DonJayamanne self-assigned this Apr 21, 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

This PR adds “auto” model support for Copilot CLI and introduces a user setting to enable/disable exposing that option through the language model provider, addressing #311779.

Changes:

  • Add github.copilot.chat.cli.autoModel.enabled setting (default: true) and wire it into Copilot CLI model resolution/model listing.
  • Update CopilotCLIModels to cache resolved LanguageModelChatInformation and prepend an auto entry when enabled.
  • Expand vitest coverage around model resolution and provideLanguageModelChatInformation behaviors (auth/no-auth, pending fetch, auth changes, setting toggle).
Show a summary per file
File Description
extensions/copilot/src/platform/configuration/common/configurationService.ts Adds a new advanced config key for enabling/disabling the auto model option in Copilot CLI.
extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotCli.ts Implements the auto model entry, caches resolved model infos, and applies the new setting in the LM provider surface.
extensions/copilot/src/extension/chatSessions/copilotcli/node/test/copilotCliModels.spec.ts Adds/updates tests for auto model resolution, provider behaviors, and the new config setting.
extensions/copilot/package.nls.json Adds localized description string for the new setting.
extensions/copilot/package.json Exposes the new setting in the extension’s configuration contribution.

Copilot's findings

Comments suppressed due to low confidence (3)

extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotCli.ts:106

  • resolveModel short-circuits auto by returning the original input string (preserving casing/whitespace). Callers (e.g. prompt-file model resolution) expect a canonical model id; returning Auto/AUTO can leak through to SDK selection and fail if the SDK expects auto. Trim/lowercase first, and return the canonical 'auto' id when enabled.
	async resolveModel(modelId: string): Promise<string | undefined> {
		if (modelId.toLowerCase() === 'auto' && this.configurationService.getConfig(ConfigKey.Advanced.CLIAutoModelEnabled)) {
			return modelId;
		}
		const models = await this.getModels();
		modelId = modelId.trim().toLowerCase();
		return models.find(m => m.id.toLowerCase() === modelId || m.name.toLowerCase() === modelId)?.id;

extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotCli.ts:167

  • provideLanguageModelChatInformation returns _resolvedModelInfos as-is once fetched, so toggling chat.cli.autoModel.enabled at runtime won’t take effect (auto may remain present/absent until an auth change). Consider filtering/prepending auto on each call based on the current setting, or listen for configuration changes to rebuild _resolvedModelInfos and fire _onDidChange.
			provideLanguageModelChatInformation: async (_options, _token) => {
				const autoModelEnabled = this.configurationService.getConfig(ConfigKey.Advanced.CLIAutoModelEnabled);
				if (!this._authenticationService.anyGitHubSession || !this._resolvedModelInfos) {
					return autoModelEnabled ? [buildAutoModel()] : [];
				}
				return this._resolvedModelInfos;
			},

extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotCli.ts:206

  • When chat.cli.autoModel.enabled is disabled, _buildModelInfos no longer marks any SDK model as default (isDefault is omitted for all non-auto models). This can result in no default model being surfaced to the language model service. Preserve the previous behavior by marking the first SDK model as default when auto is disabled (and ensure only one model is default at a time).
	private _buildModelInfos(models: CopilotCLIModelInfo[]): vscode.LanguageModelChatInformation[] {
		const isReasoningEffortEnabled = this.configurationService.getConfig(ConfigKey.Advanced.CLIThinkingEffortEnabled);
		const isAutoModelEnabled = this.configurationService.getConfig(ConfigKey.Advanced.CLIAutoModelEnabled);
		const modelsInfo: vscode.LanguageModelChatInformation[] = models.map((model, index) => {
			const multiplier = model.multiplier === undefined ? undefined : `${model.multiplier}x`;
			return {
				id: model.id,
				name: model.name,
				family: model.id,
				version: '',
				maxInputTokens: model.maxInputTokens ?? model.maxContextWindowTokens,
				maxOutputTokens: model.maxOutputTokens ?? 0,
				multiplier,
				multiplierNumeric: model.multiplier,
				isUserSelectable: true,
				configurationSchema: isReasoningEffortEnabled ? buildConfigurationSchema(model) : undefined,
				capabilities: {
					imageInput: model.supportsVision,
					toolCalling: true
				},
				targetChatSessionType: 'copilotcli'
			};
		});
		if (isAutoModelEnabled) {
			modelsInfo.unshift(buildAutoModel(models[0]));
		}
		return modelsInfo;
  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotCli.ts Outdated
DonJayamanne and others added 2 commits April 22, 2026 06:49
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

Screenshot Changes

Base: b41c9989 Current: 499ec630

Changed (3)

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

DonJayamanne and others added 3 commits April 22, 2026 07:38
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
@DonJayamanne DonJayamanne marked this pull request as ready for review April 21, 2026 21:42
@DonJayamanne DonJayamanne enabled auto-merge (squash) April 21, 2026 21:43
@DonJayamanne DonJayamanne merged commit a8458cf into main Apr 22, 2026
40 of 41 checks passed
@DonJayamanne DonJayamanne deleted the don/statistical-hornet branch April 22, 2026 05:59
@vs-code-engineering vs-code-engineering Bot added this to the 1.118.0 milestone Apr 22, 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.

Copilot CLI: Support Auto Models

3 participants