From 77d75022d6d9ed50822dae1f34a06ab46da2ec4b Mon Sep 17 00:00:00 2001 From: Ravi Tharuma <25951435+RaviTharuma@users.noreply.github.com> Date: Thu, 20 Aug 2026 16:47:58 +0200 Subject: [PATCH] fix(opencode-plugin): keep bare combo ids unprefixed (#10821) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merged — validated together with a batch of related RaviTharuma PRs in one combined worktree (typecheck:core clean, complexity/file-size/changelog gates green, focused tests passing). Thanks for the contribution! --- @omniroute/opencode-plugin/src/index.ts | 13 ++++--- .../tests/bare-combo-ids-10345.test.ts | 34 +++++++++++++++++++ .../fixes/10345-bare-combo-opencode-ids.md | 1 + 3 files changed, 44 insertions(+), 4 deletions(-) create mode 100644 @omniroute/opencode-plugin/tests/bare-combo-ids-10345.test.ts create mode 100644 changelog.d/fixes/10345-bare-combo-opencode-ids.md diff --git a/@omniroute/opencode-plugin/src/index.ts b/@omniroute/opencode-plugin/src/index.ts index bc18518cad..7c196aeccb 100644 --- a/@omniroute/opencode-plugin/src/index.ts +++ b/@omniroute/opencode-plugin/src/index.ts @@ -1294,10 +1294,15 @@ export function mapRawModelToModelV2( // `(providerID, modelID)`. If the raw id is already provider-prefixed // (e.g. `cc/claude-opus-4-7` from the `cc` Claude Code alias, or // `nvidia/llama-3-70b` from a provider that ships prefixed ids), leave - // it as-is — double-prefixing breaks OC's lookup. Otherwise prefix with - // the resolved `providerId` so a bare key like `claude-opus-4` parses as - // `(omniroute, claude-opus-4)` and the credentials resolve correctly. - id: raw.id.includes("/") ? raw.id : `${ctx.providerId}/${raw.id}`, + // it as-is — double-prefixing breaks OC's lookup. Bare **combo** ids + // (`owned_by: "combo"`, e.g. `gpt-5.6-sol`) must also stay unprefixed: + // OpenCode looks up `-m /` as model id `` under + // the plugin provider (#10345). Other bare ids still prefix with + // `providerId` so credentials resolve as `(omniroute, model)`. + id: + raw.id.includes("/") || raw.owned_by === "combo" + ? raw.id + : `${ctx.providerId}/${raw.id}`, /** * Display name. Falls back to raw.id when no enrichment is available; * the caller (`createOmniRouteProviderHook`) overlays diff --git a/@omniroute/opencode-plugin/tests/bare-combo-ids-10345.test.ts b/@omniroute/opencode-plugin/tests/bare-combo-ids-10345.test.ts new file mode 100644 index 0000000000..f7afda9ab6 --- /dev/null +++ b/@omniroute/opencode-plugin/tests/bare-combo-ids-10345.test.ts @@ -0,0 +1,34 @@ +import test from "node:test"; +import assert from "node:assert/strict"; + +import { mapRawModelToModelV2 } from "../src/index.ts"; + +test("mapRawModelToModelV2: bare combo ids stay unprefixed (#10345)", () => { + const combo = mapRawModelToModelV2( + { + id: "gpt-5.6-sol", + owned_by: "combo", + context_length: 272000, + max_output_tokens: 8192, + }, + { providerId: "omniroute", baseURL: "https://or.example.com/v1" } + ); + assert.equal(combo.id, "gpt-5.6-sol"); + assert.equal(combo.providerID, "omniroute"); + + const slashed = mapRawModelToModelV2( + { + id: "cx/gpt-5.6-sol", + owned_by: "combo", + context_length: 272000, + }, + { providerId: "omniroute", baseURL: "https://or.example.com/v1" } + ); + assert.equal(slashed.id, "cx/gpt-5.6-sol"); + + const ordinary = mapRawModelToModelV2( + { id: "claude-primary", context_length: 200000 }, + { providerId: "omniroute", baseURL: "https://or.example.com/v1" } + ); + assert.equal(ordinary.id, "omniroute/claude-primary"); +}); diff --git a/changelog.d/fixes/10345-bare-combo-opencode-ids.md b/changelog.d/fixes/10345-bare-combo-opencode-ids.md new file mode 100644 index 0000000000..c3a6a499ec --- /dev/null +++ b/changelog.d/fixes/10345-bare-combo-opencode-ids.md @@ -0,0 +1 @@ +- **fix(opencode-plugin):** publish bare combo model ids without the plugin provider prefix so OpenCode can select them ([#10345](https://github.com/diegosouzapw/OmniRoute/issues/10345))