fix: guard against empty endpoints before auto mode resolution (fixes #315295)#315301
Open
vs-code-engineering[bot] wants to merge 1 commit intomainfrom
Open
fix: guard against empty endpoints before auto mode resolution (fixes #315295)#315301vs-code-engineering[bot] wants to merge 1 commit intomainfrom
vs-code-engineering[bot] wants to merge 1 commit intomainfrom
Conversation
…315295) Add guard clauses to check for empty endpoint arrays before calling resolveAutoModeEndpoint, preventing the 'No auto mode endpoints provided' error from being thrown when models have not yet loaded. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
🔧 Error Fix
Summary
Error:
chatagenterror-No auto mode endpoints provided.Bucket:
87a1d392-9d57-7128-b9fc-5310be0c8805Impact: 823 hits, 503 users across VS Code 1.119.0
Platforms: Mac, Windows, Linux
The error is thrown in
automodeService.ts:178whenresolveAutoModeEndpointreceives an emptyknownEndpointsarray. This happens whengetAllChatEndpoints()returns empty (e.g., models not yet loaded from CAPI, network issues, or auth timing). WhileendpointProviderImpl.tshad a try/catch around this call, the error was still being constructed and thrown, which the telemetry pipeline captures at throw-time. Additionally, two call sites inlanguageModelAccess.ts(lines 240 and 367) calledresolveAutoModeEndpointwith no error handling at all.Fixes #315295
Recommended reviewer:
@lramos15Culprit Commit
No single culprit commit — this is a latent issue where
getAllChatEndpoints()can return empty during startup or network blips. The error has been present since auto mode was introduced. The spike on commit8b640eef(v1.119.0) with 814 hits / 499 users suggests increased auto mode adoption.Code Flow
sequenceDiagram participant CP as chatParticipants participant EP as endpointProviderImpl participant AM as automodeService participant LM as languageModelAccess CP->>EP: getChatEndpoint(request) EP->>EP: getAllChatEndpoints() → [] EP->>AM: resolveAutoModeEndpoint(req, []) AM-->>AM: throw Error('No auto mode endpoints') Note over AM: Error captured by telemetry at throw-time AM-->>EP: catch → fallback to copilot-base LM->>LM: getAllChatEndpoints() → [] LM->>AM: resolveAutoModeEndpoint(undefined, []) AM-->>AM: throw Error('No auto mode endpoints') Note over AM: NO catch → error propagatesAffected Files
extensions/copilot/src/platform/endpoint/node/automodeService.tsextensions/copilot/src/extension/prompt/vscode-node/endpointProviderImpl.tsextensions/copilot/src/extension/conversation/vscode-node/languageModelAccess.tsRepro Steps
getAllChatEndpoints()returns empty arrayresolveAutoModeEndpointthrows 'No auto mode endpoints provided'How the Fix Works
Chosen approach: Add guard clauses at each call site to check for empty endpoints BEFORE calling
resolveAutoModeEndpoint, preventing the error from being thrown in the first place. This follows the principle of fixing at the data producer, not the crash site.endpointProviderImpl.ts(line 83–90): MovegetAllChatEndpoints()before the try block and addif (!allEndpoints.length) return this.getChatEndpoint('copilot-base')guard. The try/catch remains as defense-in-depth for other potential errors fromresolveAutoModeEndpoint.languageModelAccess.ts(line 238–240): Addif (!allEndpoints.length) return this._currentModelsguard before callingresolveAutoModeEndpoint. When no endpoints are available, return cached models gracefully.languageModelAccess.ts(line 364–368): Addif (!allEndpoints.length) return undefinedguard in_getEndpointForModel. The caller at line 379 already handlesundefinedendpoints.Recommended Owner
@lramos15— primary author of endpointProviderImpl.ts, auto mode provider affinity, and model service resilience improvements.