opencode serve ignores model config and tries invalid model combination #8486

Open
opened 2026-02-16 18:10:05 -05:00 by yindo · 3 comments
Owner

Originally created by @utensil on GitHub (Feb 4, 2026).

Originally assigned to: @thdxr on GitHub.

Description

opencode serve does not respect the model setting in opencode.json and attempts to use an invalid model combination, resulting in a ProviderModelNotFoundError.

1076 |     const info = provider.models[modelID]
1077 |     if (!info) {
1078 |       const availableModels = Object.keys(provider.models)
1079 |       const matches = fuzzysort.go(modelID, availableModels, { limit: 3, threshold: -10000 })
1080 |       const suggestions = matches.map((m) => m.target)
1081 |       throw new ModelNotFoundError({ providerID, modelID, suggestions })
                   ^
ProviderModelNotFoundError: ProviderModelNotFoundError
 data: {
  providerID: "local",
  modelID: "claude-sonnet-4.5",
  suggestions: [],
},

      at getModel (src/provider/provider.ts:1081:13)

Configuration

~/.config/opencode/opencode.json:

{
  "model": "local/deepseek-v3.2",
  "provider": {
    "local": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://my_valid_base_url"
      },
      "models": {
        "deepseek-v3.2": {}
      }
    }
  }
}

Expected Behavior

opencode serve should use local/deepseek-v3.2 as specified in the config.

Actual Behavior

Server attempts to use local/claude-sonnet-4.5 (invalid combination) and fails to respond.

Analysis

I used claude to debug opencode source, it tells me (after some long code analysis):

## Root Cause
The defaultModel() function is somehow returning {providerID: "local", modelID: "claude-sonnet-4.5"} instead of the configured {providerID: "local", modelID: "deepseek-v3.2"}
.

This suggests either:
1. cfg.model is not being loaded correctly in server context
2. The if (cfg.model) check is failing unexpectedly
3. The fallback logic is producing an invalid model combination

## Verification
- opencode debug config shows correct config with "model": "local/deepseek-v3.2"
- opencode models shows local/deepseek-v3.2 is available
- Regular opencode CLI works fine, only opencode serve fails

## Workaround
Setting OPENCODE_MODEL=local/deepseek-v3.2 opencode serve should work by bypassing the faulty config logic.

Plugins

none

OpenCode version

1.1.50

Steps to reproduce

  1. use the following config
{
  "model": "local/deepseek-v3.2",
  "provider": {
    "local": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://my_valid_base_url"
      },
      "models": {
        "deepseek-v3.2": {}
      }
    }
  }
}
  1. opencode run 'Hi' will correctly use this model
  2. opencode serve will correctly use this model for the web sessions, but not for API driven operations such as from https://github.com/ajoslin/opencode-telegram-mirror (it works fine for other providers that has claude-sonnet-4.5)

Screenshot and/or share link

No response

Operating System

macOS 15.4.1

Terminal

ghostty

Originally created by @utensil on GitHub (Feb 4, 2026). Originally assigned to: @thdxr on GitHub. ### Description `opencode serve` does not respect the `model` setting in `opencode.json` and attempts to use an invalid model combination, resulting in a `ProviderModelNotFoundError`. ``` 1076 | const info = provider.models[modelID] 1077 | if (!info) { 1078 | const availableModels = Object.keys(provider.models) 1079 | const matches = fuzzysort.go(modelID, availableModels, { limit: 3, threshold: -10000 }) 1080 | const suggestions = matches.map((m) => m.target) 1081 | throw new ModelNotFoundError({ providerID, modelID, suggestions }) ^ ProviderModelNotFoundError: ProviderModelNotFoundError data: { providerID: "local", modelID: "claude-sonnet-4.5", suggestions: [], }, at getModel (src/provider/provider.ts:1081:13) ``` ## Configuration ~/.config/opencode/opencode.json: ```json { "model": "local/deepseek-v3.2", "provider": { "local": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://my_valid_base_url" }, "models": { "deepseek-v3.2": {} } } } } ``` ## Expected Behavior opencode serve should use `local/deepseek-v3.2` as specified in the config. ## Actual Behavior Server attempts to use `local/claude-sonnet-4.5` (invalid combination) and fails to respond. ## Analysis I used claude to debug opencode source, it tells me (after some long code analysis): ``` ## Root Cause The defaultModel() function is somehow returning {providerID: "local", modelID: "claude-sonnet-4.5"} instead of the configured {providerID: "local", modelID: "deepseek-v3.2"} . This suggests either: 1. cfg.model is not being loaded correctly in server context 2. The if (cfg.model) check is failing unexpectedly 3. The fallback logic is producing an invalid model combination ## Verification - opencode debug config shows correct config with "model": "local/deepseek-v3.2" - opencode models shows local/deepseek-v3.2 is available - Regular opencode CLI works fine, only opencode serve fails ## Workaround Setting OPENCODE_MODEL=local/deepseek-v3.2 opencode serve should work by bypassing the faulty config logic. ``` ### Plugins none ### OpenCode version 1.1.50 ### Steps to reproduce 1. use the following config ``` { "model": "local/deepseek-v3.2", "provider": { "local": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "https://my_valid_base_url" }, "models": { "deepseek-v3.2": {} } } } } ``` 2. `opencode run 'Hi'` will correctly use this model 3. `opencode serve` will correctly use this model for the web sessions, but not for API driven operations such as from https://github.com/ajoslin/opencode-telegram-mirror (it works fine for other providers that has claude-sonnet-4.5) ### Screenshot and/or share link _No response_ ### Operating System macOS 15.4.1 ### Terminal ghostty
yindo added the bug label 2026-02-16 18:10:05 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Feb 4, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #7099: Server API ignores agent's configured model when only agent parameter is passed
  • #12062: Agent model validation fails with trailing slash for custom OpenAI-compatible provider models

Both issues involve model configuration not being properly respected by the serve command and API. Feel free to ignore if your specific case differs from these.

@github-actions[bot] commented on GitHub (Feb 4, 2026): This issue might be a duplicate of existing issues. Please check: - #7099: Server API ignores agent's configured model when only agent parameter is passed - #12062: Agent model validation fails with trailing slash for custom OpenAI-compatible provider models Both issues involve model configuration not being properly respected by the serve command and API. Feel free to ignore if your specific case differs from these.
Author
Owner

@utensil commented on GitHub (Feb 4, 2026):

#7099 seems to be reporting a similar issue but it has no fix or workaround, also I'm not using any plugins

@utensil commented on GitHub (Feb 4, 2026): #7099 seems to be reporting a similar issue but it has no fix or workaround, also I'm not using any plugins
Author
Owner

@utensil commented on GitHub (Feb 4, 2026):

❯ opencode models
opencode/big-pickle
opencode/glm-4.7-free
opencode/gpt-5-nano
opencode/kimi-k2.5-free
opencode/minimax-m2.1-free
opencode/trinity-large-preview-free
local/deepseek-v3.2

(I intentionally logged out all other providers to avoid the confusion)

@utensil commented on GitHub (Feb 4, 2026): ``` ❯ opencode models opencode/big-pickle opencode/glm-4.7-free opencode/gpt-5-nano opencode/kimi-k2.5-free opencode/minimax-m2.1-free opencode/trinity-large-preview-free local/deepseek-v3.2 ``` (I intentionally logged out all other providers to avoid the confusion)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#8486