anomalyco / anomalyco/opencode

Model IDs with slashes truncated in provider-catalog.ts and bootstrap.ts

Open
#43,662 0 comments 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 20, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When using OpenRouter models with slashes in the model ID (e.g., openrouter/openrouter/free or openrouter/anthropic/claude-sonnet-4.6), the model ID is truncated at the second slash, causing "model not found" errors.

Root Cause

Two locations use simple destructuring that loses everything after the second slash:

1. packages/app/src/hooks/provider-catalog.ts:35
const [providerID, modelID] = legacy.split("/")  // BUG: loses "/free"
2. packages/app/src/context/global-sync/bootstrap.ts:283
const [providerID, id] = command.model?.split("/") ?? []  // BUG: loses "/free"

Correct Pattern

The codebase already has the correct pattern in other locations:

const [providerID, ...rest] = value.split("/")
const modelID = rest.join("/")  // Preserves "openrouter/free"

This pattern is used correctly in:

  • packages/core/src/model.ts (parse function)
  • packages/opencode/src/provider/provider.ts (parseModel)
  • packages/tui/src/util/model.ts
  • packages/tui/src/context/local.tsx
  • packages/opencode/src/cli/cmd/run.ts

Reproduction

Configure small_model in opencode.json:

{
  "small_model": "openrouter/openrouter/free"
}

On startup, opencode shows:

Warning: model not found: openrouter/openrouter

The model ID is truncated to just openrouter instead of openrouter/free.

Expected Behavior

Model IDs containing slashes should be preserved correctly, as they are in the TUI and CLI model parsing.

Suggested Fix

Update the two buggy locations to use the rest pattern:

const [providerID, ...rest] = value.split("/")
const modelID = rest.join("/")

Or call the canonical ModelV2.parse() function from packages/core/src/model.ts.

Environment

  • OpenCode version: 1.18.x (current stable)
  • Affects: OpenRouter models with slashes (e.g., openrouter/openrouter/free, openrouter/anthropic/claude-sonnet-4.6)

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.