豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Refactor model alias handling and add copilot-fast support#4745

Draft
sbatten wants to merge 8 commits intomainfrom
copilot/amateur-goat
Draft

Refactor model alias handling and add copilot-fast support#4745
sbatten wants to merge 8 commits intomainfrom
copilot/amateur-goat

Conversation

@sbatten
Copy link
Copy Markdown
Member

@sbatten sbatten commented Mar 27, 2026

Remove the ModelAliasRegistry to simplify the codebase and enhance clarity. Introduce support for the copilot-fast endpoint, including logic for its creation and management. Update related components to accommodate these changes.

@sbatten sbatten self-assigned this Mar 27, 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 removes the ModelAliasRegistry indirection and introduces a dedicated internal copilot-fast endpoint that selects a preferred “fast” model with fallback behavior, updating endpoint selection logic accordingly.

Changes:

  • Removed ModelAliasRegistry and its alias-based model resolution/registration flow.
  • Added CopilotFastChatEndpoint to resolve copilot-fast via a primary/fallback model and to force low-cost reasoning settings for Responses API requests.
  • Updated ProductionEndpointProvider and LanguageModelAccess to route copilot-fast without alias expansion.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/platform/endpoint/node/modelMetadataFetcher.ts Removes alias resolution when mapping ChatEndpointFamily → model metadata.
src/platform/endpoint/node/copilotChatEndpoint.ts Adds CopilotFastChatEndpoint with primary/fallback selection and request override behavior.
src/platform/endpoint/common/modelAliasRegistry.ts Deletes the alias registry implementation and the copilot-fast alias registration.
src/extension/prompt/vscode-node/endpointProviderImpl.ts Special-cases copilot-fast to create/cache a dedicated fast endpoint instance.
src/extension/conversation/vscode-node/languageModelAccess.ts Removes alias model injection and stops resolving endpoints via alias mapping.
Comments suppressed due to low confidence (3)

src/platform/endpoint/node/modelMetadataFetcher.ts:166

  • getChatModelFromFamily still accepts ChatEndpointFamily (which includes 'copilot-fast'), but with the alias resolution removed this method will now try to look up 'copilot-fast' in _familyMap and throw. Either re-introduce explicit handling for 'copilot-fast' here, or change the typing/contract so callers can’t pass a value that will never resolve via _familyMap.
	public async getChatModelFromFamily(family: ChatEndpointFamily): Promise<IChatModelInformation> {
		await this._taskSingler.getOrCreate(ModelMetadataFetcher.ALL_MODEL_KEY, this._fetchModels.bind(this));
		let resolvedModel: IModelAPIResponse | undefined;

		if (family === 'copilot-base') {
			resolvedModel = this._copilotBaseModel;
		} else {
			resolvedModel = this._familyMap.get(family)?.[0];
		}

src/platform/endpoint/node/copilotChatEndpoint.ts:85

  • CopilotFastChatEndpoint.create is calling modelFetcher.getChatModelFromFamily(...) with model capability families like 'gpt-5.4-nano'/'gpt-4o-mini' and forcing the types via as ChatEndpointFamily. This bypasses type-safety and makes it unclear whether getChatModelFromFamily is meant for internal endpoint families (copilot-*) or for CAPI model families. Consider introducing a separate fetcher method that takes the raw CAPI family string (or widening getChatModelFromFamily to accept string) and use that here instead of casting.
	static async create(modelFetcher: IModelMetadataFetcher, instantiationService: IInstantiationService): Promise<IChatEndpoint> {
		let modelMetadata: IChatModelInformation;
		try {
			modelMetadata = await modelFetcher.getChatModelFromFamily(CopilotFastChatEndpoint.primaryFamily as ChatEndpointFamily);
		} catch {
			modelMetadata = await modelFetcher.getChatModelFromFamily(CopilotFastChatEndpoint.fallbackFamily as ChatEndpointFamily);
		}

src/platform/endpoint/node/copilotChatEndpoint.ts:85

  • The try { ... } catch { ... } fallback in CopilotFastChatEndpoint.create will fall back on any error (including network/JSON/parsing errors), which can mask real outages and also drops the original error context if the fallback fails too. Prefer catching only the “model not available” case (if distinguishable), and/or keep the original error and rethrow an aggregated error if the fallback resolution also fails.
		try {
			modelMetadata = await modelFetcher.getChatModelFromFamily(CopilotFastChatEndpoint.primaryFamily as ChatEndpointFamily);
		} catch {
			modelMetadata = await modelFetcher.getChatModelFromFamily(CopilotFastChatEndpoint.fallbackFamily as ChatEndpointFamily);
		}

Comment thread src/platform/endpoint/node/copilotChatEndpoint.ts Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
lramos15
lramos15 previously approved these changes Mar 28, 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.

3 participants