[Bug] Duplicate OpenCode Zen / Go models after changing per-model reasoning effort
🐛 What happened
After setting a per-model option (e.g. reasoningEffort) in the model picker, every
OpenCode Zen (and Go) model is listed twice. Removing the per-model config
entry returns the list to a single set; changing the option again brings the
duplicates straight back.
Reported originally in #106 by @xianhongtao. That issue was closed as fixed in
PR #108 (0.5.2), but this is a separate trigger: the 0.5.2 fix only covers
provider groups that carry an apiKey. A per-model configuration group carries
no key, so the duplicates persist on 0.5.2.
🔄 Steps to reproduce
- Install extension 0.5.2, set the Zen (or Go) API key via the extension
command (
OpenCode Zen: Set API Key), so the key lives in SecretStorage. - Reload the window, open the model picker and count Zen models (baseline).
- Change
reasoningEfforton one Zen model in the picker submenu. - Reopen the picker and count again.
Reported numbers (VS Code 1.132.1, extension 0.5.2):
| Step | Count |
|---|---|
| Reload (no per-model config) | 7 |
| Delete per-model group via Manage Models (Cog) | 7 |
| Change reasoning effort (group recreated) | 14 |
7 unique Zen models, doubled to 14 once a per-model config group exists.
✅ What did you expect?
Each model listed exactly once regardless of per-model configuration.
🖥️ Environment
- Extension version: 0.5.2
- VS Code version: 1.132.1 (System setup, Stable)
- Provider: OpenCode Zen (also affects OpenCode Go)
- API key set via: extension command (
Set API Key)
🧠 Root cause (from chatLanguageModels.json)
chatLanguageModels.json contains a per-model configuration group for each
vendor that only has settings, no apiKey:
{
"name": "OpenCode Zen",
"vendor": "opencodezen",
"settings": {
"opencodezen:deepseek-v4-flash-free::session-2026-05-21-b::sk-***": {
"reasoningEffort": "max"
}
}
}
VS Code calls provideLanguageModelChatInformation once per configured group
for a provider that declares a configuration schema. _resolveConfiguration
on a settings-only group yields {} (no apiKey). In the extension:
- Groupless call → falls back to SecretStorage → serves N models.
- Per-model group call (
configuration: {}) →getConfiguredApiKeyis undefined → the #106 BYOK-group flag is never set → SecretStorage fallback runs again → serves N more models.
Result: N × 2 while a per-model config group exists. The #106 fix (#108) only
suppresses the groupless call when an apiKey-bearing group call has been
observed, so it does not cover this path.
🔧 Proposed fix
In provideLanguageModelChatInformation, treat a non-undefined configuration
without an apiKey as a per-model configuration group and return []:
let apiKey = getConfiguredApiKey(opts);
if (apiKey) {
await this.markByokGroupConfigured();
} else if (opts.configuration !== undefined) {
return []; // per-model config group carries no key; groupless call already serves models
}
This is safe for all known scenarios: #86 (key via command, no group), #106/#63
(groups that carry an apiKey), and agent variants (no configuration schema,
so configuration is always undefined).
📎 References
- #106 — original duplicate-model issue (fixed for apiKey-bearing groups in #108)
- #86 — SecretStorage fallback that makes this duplication possible
- #128 — duplicate report closed as dup of #106 (same root cause)
- Reporter diagnostics: #106 comment (2026-08-12) with
chatLanguageModels.jsoncontents