Describe the bug
After restarting VS Code, Custom Endpoint (BYOK) models that were previously added via Chat: Manage Language Models → Add Models → Custom Endpoint disappear from the model picker for several seconds, and sometimes never appear unless the user manually runs Developer: Reload Window.
This is caused by a startup timing race condition in the HasByokModelsContribution class.
Steps to Reproduce
- Add a Custom Endpoint model (e.g., DeepSeek, or any OpenAI-compatible endpoint) via the Language Models editor
- Verify the model works and appears in the model picker as expected
- Close all VS Code windows and reopen VS Code
- Observe: The model picker initially shows only Copilot models - the Custom Endpoint (local) option is missing
- Wait 5-15 seconds - the Custom Endpoint model eventually appears (but sometimes doesn't at all)
Expected Behavior
Custom Endpoint models that have been successfully configured should appear in the model picker immediately upon VS Code startup, without any delay.
Actual Behavior
The chat.hasByokModels.lastKnown storage key is restored as false on every cold startup, causing the github.copilot.hasByokModels context key to be false. The model picker hides all non-Copilot vendor models until the extension registration completes and triggers _update().
Technical Analysis
After inspecting the source code at src/vs/workbench/contrib/chat/browser/hasByokModelsContribution.ts, the issue is:
_restore() reads chat.hasByokModels.lastKnown from storage - this is false on first startup
- Even though
chatLanguageModels.json is already configured with valid Custom Endpoint models, the hasByokModels context key remains false
- The
_update() method only corrects this after whenInstalledExtensionsRegistered() completes
- During this window, the model picker hides all BYOK models
The key logic in _update():
if (!this._extensionsRegistered) {
if (this._contextKeyService.getContextKeyValue<boolean>(
ChatContextKeys.nonCopilotLanguageModelsAreUserSelectable.key)) {
this._setResult(true);
}
return;
}
The optimistic flip only triggers if nonCopilotLanguageModelsAreUserSelectable is set, which isnt always the case on cold start.
Additionally, for users behind an HTTP proxy (e.g. http.proxy: http://localhost:65532), the Custom Endpoint providers model validation may fail during startup if the proxy is not ready yet, causing the entire provider group to be silently dropped from the model cache.
Environment
- VS Code Version: 1.122.1
- OS Version: Windows 11
- Extension: GitHub Copilot Chat 0.50.1
- Proxy configured:
http.proxy: http://localhost:65532
Additional Context
The chat.hasByokModels.lastKnown key is stored in state.vscdb (SQLite) at %APPDATA%\Code\User\globalStorage\state.vscdb. Manually setting this to true before restart forces the models to appear immediately, confirming the root cause is the stale false value.
Related code files:
src/vs/workbench/contrib/chat/browser/hasByokModelsContribution.ts
extensions/copilot/src/extension/byok/vscode-node/customEndpointProvider.ts
src/vs/workbench/contrib/chat/common/languageModels.ts
Describe the bug
After restarting VS Code, Custom Endpoint (BYOK) models that were previously added via Chat: Manage Language Models → Add Models → Custom Endpoint disappear from the model picker for several seconds, and sometimes never appear unless the user manually runs Developer: Reload Window.
This is caused by a startup timing race condition in the HasByokModelsContribution class.
Steps to Reproduce
Expected Behavior
Custom Endpoint models that have been successfully configured should appear in the model picker immediately upon VS Code startup, without any delay.
Actual Behavior
The
chat.hasByokModels.lastKnownstorage key is restored asfalseon every cold startup, causing thegithub.copilot.hasByokModelscontext key to befalse. The model picker hides all non-Copilot vendor models until the extension registration completes and triggers_update().Technical Analysis
After inspecting the source code at
src/vs/workbench/contrib/chat/browser/hasByokModelsContribution.ts, the issue is:_restore()readschat.hasByokModels.lastKnownfrom storage - this isfalseon first startupchatLanguageModels.jsonis already configured with valid Custom Endpoint models, thehasByokModelscontext key remainsfalse_update()method only corrects this afterwhenInstalledExtensionsRegistered()completesThe key logic in
_update():The optimistic flip only triggers if
nonCopilotLanguageModelsAreUserSelectableis set, which isnt always the case on cold start.Additionally, for users behind an HTTP proxy (e.g.
http.proxy: http://localhost:65532), the Custom Endpoint providers model validation may fail during startup if the proxy is not ready yet, causing the entire provider group to be silently dropped from the model cache.Environment
http.proxy: http://localhost:65532Additional Context
The
chat.hasByokModels.lastKnownkey is stored instate.vscdb(SQLite) at%APPDATA%\Code\User\globalStorage\state.vscdb. Manually setting this totruebefore restart forces the models to appear immediately, confirming the root cause is the stalefalsevalue.Related code files:
src/vs/workbench/contrib/chat/browser/hasByokModelsContribution.tsextensions/copilot/src/extension/byok/vscode-node/customEndpointProvider.tssrc/vs/workbench/contrib/chat/common/languageModels.ts