feat(llm): add opencode-go provider support - #224
Conversation
WalkthroughAdds OpenCode Go as a new LLM provider across docs, UI, API types, configuration loading, provider discovery/registration, model mappings, routing defaults, and tests. Registers Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/config.rs (2)
4466-4483:⚠️ Potential issue | 🔴 CriticalOnboarding provider selection is index-shifted and maps to wrong providers.
The menu list and
match provider_idxmapping are out of sync. From index 10 onward, selections can bind to the wrong key/provider (e.g., choosing Ollama routes to the Gemini branch). Use one shared provider metadata table for both menu labels and selected mapping.💡 Suggested pattern (single source of truth)
+struct ProviderOption { + label: &'static str, + input_name: &'static str, + toml_key: &'static str, + provider_id: &'static str, + is_secret: bool, +} + +const PROVIDER_OPTIONS: &[ProviderOption] = &[ + // ... +]; + +let labels: Vec<&str> = PROVIDER_OPTIONS.iter().map(|option| option.label).collect(); +let provider_idx = Select::new().items(&labels).default(0).interact()?; +let selected = &PROVIDER_OPTIONS[provider_idx];Also applies to: 4525-4548
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/config.rs` around lines 4466 - 4483, The provider menu and the match provider_idx mapping are out of sync because the literal providers array (providers) and the subsequent match provider_idx branches diverge after index 10; replace the separate hard-coded menu labels and match arms with a single source of truth: define a Vec of structs or tuples (e.g., Provider { label, key }) and use that same collection to render the menu and to look up the chosen provider by index (used where match provider_idx currently appears), and apply the same change for the similar block around the 4525-4548 range so both menu labels and selection mapping always reference the same Provider entries.
2419-2425:⚠️ Potential issue | 🟠 Major
KILO_API_KEYis considered configured, but it is not actually loaded into provider config.
needs_onboarding()returns false whenKILO_API_KEYexists, yetload_from_env()doesn’t register akiloprovider from that env var. Either add full kilo env wiring or remove this bootstrap check.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/config.rs` around lines 2419 - 2425, The bootstrap check treats KILO_API_KEY as a configured credential (in the has_legacy_bootstrap_vars list) but load_from_env() never registers a kilo provider, causing needs_onboarding() to be incorrect; either remove "KILO_API_KEY" from that list or add proper wiring in load_from_env() to create and register a kilo provider from the KILO_API_KEY env var. Locate the has_legacy_bootstrap_vars declaration and either drop "KILO_API_KEY" or, if you choose wiring, update load_from_env() to read std::env::var("KILO_API_KEY") and instantiate the corresponding kilo provider/config (same pattern used for other providers) so the provider is actually registered when the env var is present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@docs/content/docs/`(deployment)/roadmap.mdx:
- Line 21: Update the provider count in the roadmap bullet that mentions
SpacebotModel and LlmManager: the text currently reads “12 providers” but the
list contains 13 entries, so change the numeric count to “13 providers” (or
remove one provider from the listed providers if that was intended) to make the
count match the listed providers (identify the sentence containing
"SpacebotModel implements Rig's CompletionModel, routes through LlmManager via
HTTP with retries and fallback chains" and adjust the numeral accordingly).
In `@src/api/providers.rs`:
- Line 315: The match in build_test_llm_config is missing a branch for
"opencode-go", so provider_config becomes None and the providers map lacks
OpenCode Go; add a new match arm for "opencode-go" (similar to the
"opencode-zen" block) that constructs a ProviderConfig with the appropriate
Provider::OpencodeGo (or equivalent variant), sets base_url (verify correct URL,
eg. https://opencode.ai/go), and uses credential for opencode_go_key so
opencode_go_key is included in the providers HashMap; ensure the new arm returns
Some(provider_config) consistent with other cases.
In `@src/config.rs`:
- Around line 322-323: The new constants and helpers (KILO_PROVIDER_BASE_URL,
default_provider_config, add_shorthand_provider) are dead code and causing CI
failures; either remove them or wire them into the provider registration flow by
updating load_from_env and from_toml to recognize shorthand providers and apply
default_provider_config when a provider entry lacks full config, and call
add_shorthand_provider when parsing shorthand strings (e.g., mapping "kilo" to
KILO_PROVIDER_BASE_URL) so these symbols are actually used during provider
loading/registration; modify load_from_env and from_toml to consult
default_provider_config and invoke add_shorthand_provider during parsing, or
delete the unused constants/functions if you prefer removal.
---
Outside diff comments:
In `@src/config.rs`:
- Around line 4466-4483: The provider menu and the match provider_idx mapping
are out of sync because the literal providers array (providers) and the
subsequent match provider_idx branches diverge after index 10; replace the
separate hard-coded menu labels and match arms with a single source of truth:
define a Vec of structs or tuples (e.g., Provider { label, key }) and use that
same collection to render the menu and to look up the chosen provider by index
(used where match provider_idx currently appears), and apply the same change for
the similar block around the 4525-4548 range so both menu labels and selection
mapping always reference the same Provider entries.
- Around line 2419-2425: The bootstrap check treats KILO_API_KEY as a configured
credential (in the has_legacy_bootstrap_vars list) but load_from_env() never
registers a kilo provider, causing needs_onboarding() to be incorrect; either
remove "KILO_API_KEY" from that list or add proper wiring in load_from_env() to
create and register a kilo provider from the KILO_API_KEY env var. Locate the
has_legacy_bootstrap_vars declaration and either drop "KILO_API_KEY" or, if you
choose wiring, update load_from_env() to read std::env::var("KILO_API_KEY") and
instantiate the corresponding kilo provider/config (same pattern used for other
providers) so the provider is actually registered when the env var is present.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (11)
docs/content/docs/(configuration)/config.mdxdocs/content/docs/(deployment)/roadmap.mdxinterface/src/api/client.tsinterface/src/components/ModelSelect.tsxinterface/src/lib/providerIcons.tsxinterface/src/routes/Settings.tsxsrc/api/models.rssrc/api/providers.rssrc/config.rssrc/llm/providers.rssrc/llm/routing.rs
| - **Multi-agent** — per-agent database isolation, `Agent` struct bundles all dependencies | ||
| - **Database connections** — SQLite + LanceDB + redb per-agent, migrations for all tables | ||
| - **LLM** — `SpacebotModel` implements Rig's `CompletionModel`, routes through `LlmManager` via HTTP with retries and fallback chains across 11 providers (Anthropic, OpenAI, OpenRouter, Z.ai, Groq, Together, Fireworks, DeepSeek, xAI, Mistral, OpenCode Zen) | ||
| - **LLM** — `SpacebotModel` implements Rig's `CompletionModel`, routes through `LlmManager` via HTTP with retries and fallback chains across 12 providers (Anthropic, OpenAI, OpenRouter, Kilo Gateway, Z.ai, Groq, Together, Fireworks, DeepSeek, xAI, Mistral, OpenCode Zen, OpenCode Go) |
There was a problem hiding this comment.
Provider count is off by one in this roadmap bullet.
The sentence says “12 providers,” but the list names 13 providers. Please align the count to the listed items.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@docs/content/docs/`(deployment)/roadmap.mdx at line 21, Update the provider
count in the roadmap bullet that mentions SpacebotModel and LlmManager: the text
currently reads “12 providers” but the list contains 13 entries, so change the
numeric count to “13 providers” (or remove one provider from the listed
providers if that was intended) to make the count match the listed providers
(identify the sentence containing "SpacebotModel implements Rig's
CompletionModel, routes through LlmManager via HTTP with retries and fallback
chains" and adjust the numeral accordingly).
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/config.rs (1)
4298-4315:⚠️ Potential issue | 🟠 MajorFix onboarding provider index drift (wrong provider gets configured).
After adding "OpenCode Go" in the menu, the numeric
provider_idxmapping is misaligned. For example, selecting OpenCode Go (Line 4311) currently resolves to the OpenCode Zen branch, and downstream options are shifted as well.💡 Minimal fix (realign menu and match)
let providers = &[ "Anthropic", "OpenRouter", "OpenAI", "Z.ai (GLM)", "Groq", "Together AI", "Fireworks AI", "DeepSeek", "xAI (Grok)", "Mistral AI", + "Google Gemini", "Ollama", "OpenCode Zen", "OpenCode Go", "MiniMax", "Moonshot AI (Kimi)", "Z.AI Coding Plan", ]; @@ - 16 => ( + 16 => ( "Z.AI Coding Plan API key", "zai_coding_plan_key", "zai-coding-plan", ), - 17 => ("Kilo Gateway API key", "kilo_key", "kilo"), _ => unreachable!(), };Also applies to: 4357-4380
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/config.rs` around lines 4298 - 4315, The providers array in src/config.rs is out of sync with the numeric provider_idx mapping causing selections (e.g., "OpenCode Go") to resolve to the wrong branch; update the providers list to match the ordering expected by the code that reads provider_idx (and any switch/if that branches on provider_idx around the provider handling code between the providers declaration and the later mapping block around lines referenced) so each string in the providers slice corresponds exactly to the numeric indices used downstream (also check and realign the second occurrence noted at the block around 4357-4380), ensuring the new "OpenCode Go" entry is placed at the correct index and all subsequent provider entries are shifted accordingly to preserve existing mappings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/config.rs`:
- Around line 4298-4315: The providers array in src/config.rs is out of sync
with the numeric provider_idx mapping causing selections (e.g., "OpenCode Go")
to resolve to the wrong branch; update the providers list to match the ordering
expected by the code that reads provider_idx (and any switch/if that branches on
provider_idx around the provider handling code between the providers declaration
and the later mapping block around lines referenced) so each string in the
providers slice corresponds exactly to the numeric indices used downstream (also
check and realign the second occurrence noted at the block around 4357-4380),
ensuring the new "OpenCode Go" entry is placed at the correct index and all
subsequent provider entries are shifted accordingly to preserve existing
mappings.
| @@ -4264,6 +4307,7 @@ pub fn run_onboarding() -> anyhow::Result<Option<PathBuf>> { | |||
| "Mistral AI", | |||
| "Ollama", | |||
There was a problem hiding this comment.
The providers menu and the match provider_idx mapping are out of sync here: index 10 is treated as Gemini in the match, but the menu jumps from Mistral → Ollama.
| "Ollama", | |
| "Google Gemini", | |
| "Ollama", |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/config.rs (1)
4297-4314:⚠️ Potential issue | 🟠 MajorFix onboarding provider index mismatch (currently writes the wrong key/provider).
At Line 4297 the menu options no longer include Gemini, but the
match provider_idxtable (Line 4356+) still assumes Gemini at index 10. That makes “Ollama” map togemini_key, shifts later providers, and leaves the last provider mapping unreachable from the UI.🔧 Proposed fix (re-align indices by restoring the missing menu item)
let providers = &[ "Anthropic", "OpenRouter", "OpenAI", "Z.ai (GLM)", "Groq", "Together AI", "Fireworks AI", "DeepSeek", "xAI (Grok)", "Mistral AI", + "Google Gemini", "Ollama", "OpenCode Zen", "OpenCode Go", "MiniMax", "Moonshot AI (Kimi)", "Z.AI Coding Plan", ];Also applies to: 4356-4378
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/config.rs` around lines 4297 - 4314, The provider menu array `providers` is missing the "Gemini" entry which causes the `match provider_idx` mapping (the arms that reference keys like `gemini_key`, `ollama_key`, etc.) to be shifted; restore the missing "Gemini" item at the correct position in the `providers` array (so indices align with the existing match arms), or alternatively update the `match provider_idx` arms to reflect the current list order—ensure that the arm referencing `gemini_key` corresponds to the "Gemini" label and that `ollama_key` and subsequent keys map to their intended provider labels.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/config.rs`:
- Around line 4297-4314: The provider menu array `providers` is missing the
"Gemini" entry which causes the `match provider_idx` mapping (the arms that
reference keys like `gemini_key`, `ollama_key`, etc.) to be shifted; restore the
missing "Gemini" item at the correct position in the `providers` array (so
indices align with the existing match arms), or alternatively update the `match
provider_idx` arms to reflect the current list order—ensure that the arm
referencing `gemini_key` corresponds to the "Gemini" label and that `ollama_key`
and subsequent keys map to their intended provider labels.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
docs/content/docs/(deployment)/roadmap.mdxsrc/api/providers.rssrc/config.rs
✅ Files skipped from review due to trivial changes (1)
- src/api/providers.rs
|
Superseded by #225 |
… (fp:71617f0ad28f) tool_workspace() no longer silently degrades to the shared checkout when an isolated workspace was provisioned but has no worktrees. It now consults the workspace's Isolation completeness signal: the empty-because-nothing-to- isolate case falls back cleanly, but repos-present-yet-none-isolated trips a debug_assert! in debug builds and logs at error (loud, greppable) in release, documenting why the degradation is non-recoverable (re-opens issue spacedriveapp#224).
Summary
This PR adds first-class support for OpenCode Go and cleans up model definitions by leveraging models.dev for providers that are now available there.
Changes
opencode_go_keyandOPENCODE_GO_API_KEYsupport in config, with automatic provider registrationopencode→opencode-zen,opencode-go,zai-coding-plan,minimax,moonshotai→moonshotextra_models()that are now fetched from models.dev:extra_models(): minimax-cn, moonshot-v1-8kWhy
OpenCode Go is an OpenAI-compatible inference provider offering kimi-k2.5, glm-5, and minimax-m2.5. This integration makes it work out of the box with proper routing. Additionally, models.dev now hosts most of our previously hardcoded models, so we fetch them dynamically instead of maintaining duplicates.