anomalyco / anomalyco/opencode

Desktop app double-prefixes OpenRouter model IDs when loading from workspace file

Open
#47,690 2 comments 1 reaction 1 assignee View on GitHub

@nexxeln is already working on this.

Since Sep 6, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Description

Summary:

When a model is selected via the desktop app's model picker, the model selection is stored in the workspace file as two separate fields:

"model": {
  "providerID": "openrouter",
  "modelID": "z-ai/glm-5.3-flash"
}

The modelID already includes the provider prefix (z-ai/). When the backend later loads the model from this workspace file, it concatenates providerID + "/" + modelID, producing openrouter/z-ai/glm-5.3-flash — which does not exist as a valid model slug.

The TUI does not have this bug because it sets the model at session creation time as model.id and model.providerID separately, and the backend handles that path correctly.

Evidence from logs:

Broken path (model loaded from workspace file):

ProviderModelNotFoundError: Model not found: openrouter/z-ai/glm-5.3-flash.
Did you mean: z-ai/glm-5.3-flash?

Working path (model set at session creation):

created id=ses_... model.id=z-ai/glm-5.3-flash model.providerID=openrouter
stream providerID=openrouter modelID=z-ai/glm-5.3-flash

The same bug affects all OpenRouter models with a slash in the slug:

  • openrouter/z-ai/glm-5.3-flash (should be z-ai/glm-5.3-flash)
  • openrouter/~deepseek/deepseek-v4-flash-latest (should be ~deepseek/deepseek-v4-flash-latest)
  • openrouter/inclusionai/ling-3.0-flash-sante:free (should be inclusionai/ling-3.0-flash-sante:free)

Root cause:

The backend's model resolution logic unconditionally prepends providerID/ to modelID when loading from the workspace file, without checking whether modelID already contains a provider prefix. The correct behavior is to use modelID as-is when providerID is already set as a separate field.

Workaround:

Set the model in ~/.config/opencode/opencode.jsonc at the top level so it is set at session creation time rather than loaded from the workspace file:

{
  "$schema": "https://opencode.ai/config.json",
  "model": "openrouter/z-ai/glm-5.3-flash"
}
Plugins

Openrouter integration

OpenCode version

OpenCode Desktop 1.18.29

Steps to reproduce
  1. Open OpenCode Desktop (not TUI)
  2. Connect OpenRouter provider
  3. Select any OpenRouter model from the model picker (e.g., z-ai/glm-5.3-flash)
  4. Submit a prompt
  5. Prompt fails immediately with ProviderModelNotFoundError
Screenshot and/or share link

No response

Operating System

macOS 26.5.2

Terminal

None, desktop version

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.