Skip to content

fix: convert OpenCode model format to CLI slash format#605

Merged
stefandevo merged 2 commits intov0.13.0rcfrom
opencode-fixes
Jan 19, 2026
Merged

fix: convert OpenCode model format to CLI slash format#605
stefandevo merged 2 commits intov0.13.0rcfrom
opencode-fixes

Conversation

@stefandevo
Copy link
Copy Markdown
Collaborator

@stefandevo stefandevo commented Jan 19, 2026

Summary

Fixes OpenCode CLI model format conversion that was broken after commit 4b0d1399 changed model IDs from slash format (opencode/model) to prefix format (opencode-model).

Problem

After selecting an OpenCode model (e.g., "Big Pickle"), the CLI would fail with:

ProviderModelNotFoundError
  providerID: "big-pickle"
  modelID: ""

The CLI was receiving --model big-pickle instead of --model opencode/big-pickle.

Root Cause

  1. Commit 4b0d1399 ("feat: implement cursor model migration and enhance auto mode functionality") changed OpenCode model IDs from opencode/big-pickle to opencode-big-pickle
  2. The buildCliArgs() method in opencode-provider.ts was not updated to convert the new format back to CLI format
  3. simple-query-service.ts calls stripProviderPrefix() which strips opencode- prefix
  4. Result: bare model name big-pickle was passed to CLI, which interpreted it as a provider ID

Solution

Updated buildCliArgs() to properly convert model formats:

Input (after prefix strip) CLI Argument Reason
big-pickle opencode/big-pickle Bare name → prepend opencode/
glm-4.7-free opencode/glm-4.7-free Bare name → prepend opencode/
github-copilot/gpt-4o github-copilot/gpt-4o Has slash → pass through
google/gemini-2.5-pro google/gemini-2.5-pro Has slash → pass through

This handles all 100+ dynamic provider models correctly - the slash detection ensures dynamic models pass through unchanged.

Testing

  • Server unit tests pass (npm run test:server)
  • Manual test: Select OpenCode model, run feature, verify no error

Files Changed

  • apps/server/src/providers/opencode-provider.ts - Updated buildCliArgs() method

Summary by CodeRabbit

  • Bug Fixes
    • Improved model name handling so different model naming formats and prefixes (including provider-qualified names) are consistently translated for CLI use, preventing mismatches when specifying models.

✏️ Tip: You can customize this high-level summary in your review settings.

The OpenCode CLI expects models in provider/model format (e.g., opencode/big-pickle),
but after commit 4b0d139 changed model IDs from slash format to prefix format,
the buildCliArgs() method was not updated to convert back to CLI format.

Root cause:
- Commit 4b0d139 changed OpenCode model IDs from opencode/model to opencode-model
- The old code used stripProviderPrefix() which just removed the prefix
- This resulted in bare model names (e.g., "big-pickle") being passed to CLI
- CLI interpreted "big-pickle" as a provider ID, causing ProviderModelNotFoundError

Fix:
- Updated buildCliArgs() to properly convert model formats for CLI
- Bare model names (after prefix strip) now get opencode/ prepended
- Models with slashes (dynamic providers) pass through unchanged

Model conversion examples:
- opencode-big-pickle → (stripped to) big-pickle → opencode/big-pickle
- opencode-github-copilot/gpt-4o → (stripped to) github-copilot/gpt-4o → github-copilot/gpt-4o
- google/gemini-2.5-pro → google/gemini-2.5-pro (unchanged)
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @stefandevo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical bug in the OpenCode integration where model selection was failing due to an incompatibility in model ID formats between the application's internal representation and the OpenCode CLI's expectations. The changes introduce robust logic to correctly translate model identifiers, ensuring that all OpenCode models are passed to the CLI in the required slash-separated format, thereby restoring proper functionality.

Highlights

  • Fixes OpenCode CLI Model Format Conversion: This pull request resolves an issue where the OpenCode CLI failed to correctly process model IDs due to a format mismatch. Previously, a commit changed model IDs from a slash format (e.g., opencode/model) to a prefix format (e.g., opencode-model), but the CLI argument builder was not updated to reflect this change.
  • Incorrect Model ID Handling: The buildCliArgs() method in opencode-provider.ts was not updated to convert the new opencode- prefixed model IDs back to the opencode/ slash format expected by the CLI. This resulted in bare model names being passed, leading to ProviderModelNotFoundError.
  • Updated Model ID Conversion Logic: The buildCliArgs() method has been enhanced to correctly convert model IDs. It now strips the opencode- prefix and prepends opencode/ for bare OpenCode models, while preserving models already in provider/model slash format (e.g., github-copilot/gpt-4o).
  • Removal of stripProviderPrefix: The stripProviderPrefix utility function is no longer needed for OpenCode model ID processing within opencode-provider.ts and has been removed.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 19, 2026

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

📝 Walkthrough

Walkthrough

OpencodeProvider's model formatting in buildCliArgs was changed: instead of stripping a provider prefix, the code now converts input model names into CLI-ready --model values by handling opencode-prefixed names, provider/model forms, bare names, and already provider-qualified names with specific rules.

Changes

Cohort / File(s) Summary
OpencodeProvider Model Translation
apps/server/src/providers/opencode-provider.ts
Removed stripProviderPrefix import and replaced prior stripping logic with conversion rules: if model starts with opencode-, drop prefix then if it contains / use as-is, otherwise prefix with opencode/; if model already contains / use directly; pass resulting cliModel to --model. Comments updated.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A model once peeled, now smartly dressed,
I hop and tweak each name with zest,
Slashes kept and prefixes sown,
Opencode paths find their own home.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly and accurately describes the main change: converting OpenCode model format from prefix format (opencode-model) back to CLI slash format (opencode/model) in buildCliArgs().
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a bug where OpenCode model IDs were not being correctly formatted for the CLI, causing errors when selecting models. The fix introduces logic to convert model IDs from the internal opencode-model format to the opencode/model format expected by the CLI. The changes correctly handle various cases, including models from other providers. My review includes a suggestion to refactor the new logic for improved conciseness and maintainability.

Comment thread apps/server/src/providers/opencode-provider.ts Outdated
Address review feedback from Gemini Code Assist to reduce code repetition.
The conditional logic for handling models with/without slashes is now
unified into a simpler two-step approach:
1. Strip opencode- prefix if present
2. Prepend opencode/ if no slash exists
@stefandevo stefandevo merged commit ea3930c into v0.13.0rc Jan 19, 2026
8 checks passed
@stefandevo stefandevo deleted the opencode-fixes branch January 19, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant