fix: convert OpenCode model format to CLI slash format#605
fix: convert OpenCode model format to CLI slash format#605stefandevo merged 2 commits intov0.13.0rcfrom
Conversation
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)
Summary of ChangesHello @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
🧠 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 AssistThe 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
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 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
|
|
Note Other AI code review bot(s) detectedCodeRabbit 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. 📝 WalkthroughWalkthroughOpencodeProvider's model formatting in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
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.
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
Summary
Fixes OpenCode CLI model format conversion that was broken after commit
4b0d1399changed 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:
The CLI was receiving
--model big-pickleinstead of--model opencode/big-pickle.Root Cause
4b0d1399("feat: implement cursor model migration and enhance auto mode functionality") changed OpenCode model IDs fromopencode/big-pickletoopencode-big-picklebuildCliArgs()method inopencode-provider.tswas not updated to convert the new format back to CLI formatsimple-query-service.tscallsstripProviderPrefix()which stripsopencode-prefixbig-picklewas passed to CLI, which interpreted it as a provider IDSolution
Updated
buildCliArgs()to properly convert model formats:big-pickleopencode/big-pickleopencode/glm-4.7-freeopencode/glm-4.7-freeopencode/github-copilot/gpt-4ogithub-copilot/gpt-4ogoogle/gemini-2.5-progoogle/gemini-2.5-proThis handles all 100+ dynamic provider models correctly - the slash detection ensures dynamic models pass through unchanged.
Testing
npm run test:server)Files Changed
apps/server/src/providers/opencode-provider.ts- UpdatedbuildCliArgs()methodSummary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.