Refactor model alias handling and add copilot-fast support#4745
Draft
Refactor model alias handling and add copilot-fast support#4745
Conversation
Contributor
There was a problem hiding this comment.
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
ModelAliasRegistryand its alias-based model resolution/registration flow. - Added
CopilotFastChatEndpointto resolvecopilot-fastvia a primary/fallback model and to force low-cost reasoning settings for Responses API requests. - Updated
ProductionEndpointProviderandLanguageModelAccessto routecopilot-fastwithout 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
getChatModelFromFamilystill acceptsChatEndpointFamily(which includes'copilot-fast'), but with the alias resolution removed this method will now try to look up'copilot-fast'in_familyMapand 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.createis callingmodelFetcher.getChatModelFromFamily(...)with model capability families like'gpt-5.4-nano'/'gpt-4o-mini'and forcing the types viaas ChatEndpointFamily. This bypasses type-safety and makes it unclear whethergetChatModelFromFamilyis 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 wideninggetChatModelFromFamilyto acceptstring) 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 inCopilotFastChatEndpoint.createwill 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);
}
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
lramos15
previously approved these changes
Mar 28, 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.
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.