Skip to content

fix(server): send OpenCode Go models as bare runtime IDs - #7247

Open
imMxts wants to merge 4 commits into
pingdotgg:mainfrom
imMxts:cursor/opencode-go-model-id-bcd6
Open

fix(server): send OpenCode Go models as bare runtime IDs#7247
imMxts wants to merge 4 commits into
pingdotgg:mainfrom
imMxts:cursor/opencode-go-model-id-bcd6

Conversation

@imMxts

@imMxts imMxts commented Aug 16, 2026

Copy link
Copy Markdown

What Changed

Inventory slugs for OpenCode models are built from the catalog map key, not model.id. sendTurn and text generation then strip a duplicated opencode/ or opencode-go/ prefix before the runtime request, so Go models go out as { providerID: "opencode-go", modelID: "deepseek-v4-pro" }. Other catalogs that legitimately use a key starting with provider/ are left alone.

Why

Fixes #3571. When model.id was already namespaced, the picker stored opencode-go/opencode-go/deepseek-v4-pro. First-slash parse then sent modelID: "opencode-go/deepseek-v4-pro", which OpenCode's getModel rejects.

Not covered: a correctly split { providerID: "opencode-go", modelID: "deepseek-v4-pro" } can still fail if the spawned OpenCode server does not have that model in its live catalog (auth/subscription). That is outside this serialization fix.

UI Changes

None.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • N/A — no UI changes
  • N/A — no animation/interaction changes

Note

Low Risk
Targeted serialization and inventory slug logic for OpenCode models with broad test coverage; no auth or data-path changes.

Overview
Fixes OpenCode Go / Zen model selection when inventory model.id is already namespaced, which produced slugs like opencode-go/opencode-go/deepseek-v4-pro and caused the runtime to reject the request.

Inventory slugs are now built from each provider’s catalog map key (provider.id + key), not from model.id, so the picker exposes opencode-go/deepseek-v4-pro even when JSON id is prefixed.

Runtime requests (sendTurn, text generation) go through toOpenCodeRuntimeModel, which splits provider/model and, for hosted opencode / opencode-go only, strips a repeated provider prefix from modelID. Keys that legitimately start with provider/ (e.g. Hugging Face) are unchanged. Bare model IDs still fail validation with the existing provider/model message.

Reviewed by Cursor Bugbot for commit fb8becd. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix OpenCode Go model slugs to send bare runtime IDs by stripping duplicated provider prefixes

  • flattenOpenCodeModels in OpenCodeProvider.ts now builds slugs from the inventory map key instead of model.id, avoiding duplicated prefixes like opencode-go/opencode-go/....
  • Adds toOpenCodeRuntimeModel in opencodeRuntime.ts which strips repeated leading provider segments for hosted OpenCode providers (opencode, opencode-go) while leaving other providers unchanged.
  • Replaces parseOpenCodeModelSlug with toOpenCodeRuntimeModel in the sendTurn handler and text generation path so duplicated prefixes are normalized before the CLI is invoked.
  • Bare model IDs without a provider namespace are still rejected as invalid.

Macroscope summarized fb8becd.

cursoragent and others added 2 commits August 16, 2026 18:16
)

OpenCode looks up provider.models[modelID], so a duplicated
opencode-go/ prefix on the model ID is rejected. Keep the
application slug namespaced and strip the extra prefix at the
OpenCode runtime seam. Inventory slugs now use the catalog map
key so discovery matches that same request shape.

Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>
General duplicate-prefix stripping would rewrite a legitimate catalog
key that starts with provider/ (huggingface/huggingface/CodeBERTa).
Keep first-slash parsing for all providers, and only peel a repeated
opencode or opencode-go prefix at the runtime seam. Inventory still
uses the catalog map key.

Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>
@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 16, 2026
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 849dc52c-0ca9-4c6e-8c7e-8442f448ffbc

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@imMxts imMxts changed the title fix(server): send OpenCode Go models as bare runtime IDs (#3571) fix(server): send OpenCode Go models as bare runtime IDs Aug 16, 2026
Drop duplicate sendTurn copies that the runtime helper unit tests
already cover, matching the smaller first-time contributor PRs that
landed.

Co-authored-by: Mats Varnskühler <imMxts@users.noreply.github.com>
@imMxts
imMxts marked this pull request as ready for review August 16, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenCode adapter requires provider/model, but OpenCode Go runtime rejects opencode-go/<model> and expects bare model id

2 participants