Skip to content

fix: guard against empty endpoints before auto mode resolution (fixes #315295)#315301

Open
vs-code-engineering[bot] wants to merge 1 commit intomainfrom
fix/auto-mode-empty-endpoints-315295-6a2de2400c6564d4
Open

fix: guard against empty endpoints before auto mode resolution (fixes #315295)#315301
vs-code-engineering[bot] wants to merge 1 commit intomainfrom
fix/auto-mode-empty-endpoints-315295-6a2de2400c6564d4

Conversation

@vs-code-engineering
Copy link
Copy Markdown
Contributor

🔧 Error Fix

Summary

Error: chatagenterror-No auto mode endpoints provided.
Bucket: 87a1d392-9d57-7128-b9fc-5310be0c8805
Impact: 823 hits, 503 users across VS Code 1.119.0
Platforms: Mac, Windows, Linux

The error is thrown in automodeService.ts:178 when resolveAutoModeEndpoint receives an empty knownEndpoints array. This happens when getAllChatEndpoints() returns empty (e.g., models not yet loaded from CAPI, network issues, or auth timing). While endpointProviderImpl.ts had 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 in languageModelAccess.ts (lines 240 and 367) called resolveAutoModeEndpoint with no error handling at all.

Fixes #315295
Recommended reviewer: @lramos15

Culprit 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 commit 8b640eef (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 propagates
Loading

Affected Files

File Role
extensions/copilot/src/platform/endpoint/node/automodeService.ts Throws error when knownEndpoints is empty (line 178)
extensions/copilot/src/extension/prompt/vscode-node/endpointProviderImpl.ts Calls resolveAutoModeEndpoint with try/catch (line 86)
extensions/copilot/src/extension/conversation/vscode-node/languageModelAccess.ts Two unguarded calls to resolveAutoModeEndpoint (lines 240, 367)

Repro Steps

  1. Start VS Code with auto model selected
  2. Initiate a chat request before models finish loading from CAPI
  3. getAllChatEndpoints() returns empty array
  4. resolveAutoModeEndpoint throws '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.

  1. endpointProviderImpl.ts (line 83–90): Move getAllChatEndpoints() before the try block and add if (!allEndpoints.length) return this.getChatEndpoint('copilot-base') guard. The try/catch remains as defense-in-depth for other potential errors from resolveAutoModeEndpoint.

  2. languageModelAccess.ts (line 238–240): Add if (!allEndpoints.length) return this._currentModels guard before calling resolveAutoModeEndpoint. When no endpoints are available, return cached models gracefully.

  3. languageModelAccess.ts (line 364–368): Add if (!allEndpoints.length) return undefined guard in _getEndpointForModel. The caller at line 379 already handles undefined endpoints.

Recommended Owner

@lramos15 — primary author of endpointProviderImpl.ts, auto mode provider affinity, and model service resilience improvements.

Generated by errors-fix · ● 8M ·

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Error] chatagenterror-No auto mode endpoints provided.

1 participant