anomalyco / anomalyco/opencode
Desktop app double-prefixes OpenRouter model IDs when loading from workspace file
@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 bez-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 beinclusionai/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
- Open OpenCode Desktop (not TUI)
- Connect OpenRouter provider
- Select any OpenRouter model from the model picker (e.g.,
z-ai/glm-5.3-flash) - Submit a prompt
- Prompt fails immediately with
ProviderModelNotFoundError
Screenshot and/or share link
No response
Operating System
macOS 26.5.2
Terminal
None, desktop version
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.