CLI run --model fails for namespaced models with : or multi-segment paths (truncates modelID → ProviderModelNotFoundError) #2632

Closed
opened 2026-02-16 17:36:33 -05:00 by yindo · 3 comments
Owner

Originally created by @wojons on GitHub (Nov 6, 2025).

Description

opencode run errors out when the --model value includes a colon (:) or multiple path segments after the provider prefix. It looks like the CLI/model parser truncates modelID to only the first segment (and possibly to the part before :), which leads to ProviderModelNotFoundError at src/provider/provider.ts:553.

Single-segment models (e.g., opencode/grok-code) work; namespaced ones like synthetic/hf:MiniMaxAI/MiniMax-M2 and chutes/moonshotai/Kimi-K2-Instruct-0905 do not.

Steps to Reproduce

Run:

opencode run --agent anything-agent --model synthetic/hf:MiniMaxAI/MiniMax-M2 --prompt "hello"

Or:

opencode run --agent anything-agent --model chutes/moonshotai/Kimi-K2-Instruct-0905 --prompt "hello"

Actual Behavior

The model ID is truncated and the provider layer can’t find it:

INFO 2025-11-06T10:11:54 +0ms service=provider providerID=synthetic modelID=hf:MiniMaxAI getModel
548 | })
549 |
550 | const provider = s.providers[providerID]
551 | if (!provider) throw new ModelNotFoundError({ providerID, modelID })
552 | const info = provider.info.models[modelID]
553 | if (!info) throw new ModelNotFoundError({ providerID, modelID })
^
ProviderModelNotFoundError: ProviderModelNotFoundError
data: {
providerID: "synthetic",
modelID: "hf:MiniMaxAI",
},

  at getModel (src/provider/provider.ts:553:22)

And with another provider:

INFO 2025-11-06T10:17:12 +0ms service=provider providerID=chutes modelID=moonshotai getModel
548 | })
549 |
550 | const provider = s.providers[providerID]
551 | if (!provider) throw new ModelNotFoundError({ providerID, modelID })
552 | const info = provider.info.models[modelID]
553 | if (!info) throw new ModelNotFoundError({ providerID, modelID })
^
ProviderModelNotFoundError: ProviderModelNotFoundError
data: {
providerID: "chutes",
modelID: "moonshotai",
},

  at getModel (src/provider/provider.ts:553:22)

Note: When I log what my script is sending right before the run, it shows:

synthetic/hf:MiniMaxAI/MiniMax-M2

…but the provider layer ends up seeing modelID="hf:MiniMaxAI" (missing /MiniMax-M2).
Similarly, chutes/moonshotai/Kimi-K2-Instruct-0905 is observed as modelID="moonshotai" (missing /Kimi-K2-Instruct-0905).

Expected Behavior

The parser should preserve the full model path after the provider prefix.

synthetic/hf:MiniMaxAI/MiniMax-M2 → providerID="synthetic", modelID="hf:MiniMaxAI/MiniMax-M2"

chutes/moonshotai/Kimi-K2-Instruct-0905 → providerID="chutes", modelID="moonshotai/Kimi-K2-Instruct-0905"

These models should resolve if they exist in provider.info.models.

Additional Notes

Works fine with a simple, single-segment model like opencode/grok-code.

This looks like a parsing/normalization bug where --model is split on / and/or : and only the first segment is kept as modelID. If a : is treated as a provider separator elsewhere, it likely needs escaping or a different rule inside the model portion.

Suggested Fix

Adjust the --model parsing to:

Treat the string as providerID + / + <modelID...>, where <modelID...> may include additional / segments and colons.

Avoid splitting the <modelID...> on :; only the very first / should separate the provider from the rest.

Add tests:

synthetic/hf:MiniMaxAI/MiniMax-M2 → ["synthetic", "hf:MiniMaxAI/MiniMax-M2"]

chutes/moonshotai/Kimi-K2-Instruct-0905 → ["chutes", "moonshotai/Kimi-K2-Instruct-0905"]

Environment

opencode version: opencode --version

Node.js version: node -v

OS: macOS/Linux/Windows (version/build)

Shell: bash/zsh/pwsh

Workarounds Tried

Using a simpler model slug (works).

Quoting the --model value (still reproduces).

N/A otherwise.

OpenCode version

No response

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @wojons on GitHub (Nov 6, 2025). ### Description opencode run errors out when the --model value includes a colon (:) or multiple path segments after the provider prefix. It looks like the CLI/model parser truncates modelID to only the first segment (and possibly to the part before :), which leads to ProviderModelNotFoundError at src/provider/provider.ts:553. Single-segment models (e.g., opencode/grok-code) work; namespaced ones like synthetic/hf:MiniMaxAI/MiniMax-M2 and chutes/moonshotai/Kimi-K2-Instruct-0905 do not. Steps to Reproduce Run: opencode run --agent anything-agent --model synthetic/hf:MiniMaxAI/MiniMax-M2 --prompt "hello" Or: opencode run --agent anything-agent --model chutes/moonshotai/Kimi-K2-Instruct-0905 --prompt "hello" Actual Behavior The model ID is truncated and the provider layer can’t find it: INFO 2025-11-06T10:11:54 +0ms service=provider providerID=synthetic modelID=hf:MiniMaxAI getModel 548 | }) 549 | 550 | const provider = s.providers[providerID] 551 | if (!provider) throw new ModelNotFoundError({ providerID, modelID }) 552 | const info = provider.info.models[modelID] 553 | if (!info) throw new ModelNotFoundError({ providerID, modelID }) ^ ProviderModelNotFoundError: ProviderModelNotFoundError data: { providerID: "synthetic", modelID: "hf:MiniMaxAI", }, at getModel (src/provider/provider.ts:553:22) And with another provider: INFO 2025-11-06T10:17:12 +0ms service=provider providerID=chutes modelID=moonshotai getModel 548 | }) 549 | 550 | const provider = s.providers[providerID] 551 | if (!provider) throw new ModelNotFoundError({ providerID, modelID }) 552 | const info = provider.info.models[modelID] 553 | if (!info) throw new ModelNotFoundError({ providerID, modelID }) ^ ProviderModelNotFoundError: ProviderModelNotFoundError data: { providerID: "chutes", modelID: "moonshotai", }, at getModel (src/provider/provider.ts:553:22) Note: When I log what my script is sending right before the run, it shows: synthetic/hf:MiniMaxAI/MiniMax-M2 …but the provider layer ends up seeing modelID="hf:MiniMaxAI" (missing /MiniMax-M2). Similarly, chutes/moonshotai/Kimi-K2-Instruct-0905 is observed as modelID="moonshotai" (missing /Kimi-K2-Instruct-0905). Expected Behavior The parser should preserve the full model path after the provider prefix. synthetic/hf:MiniMaxAI/MiniMax-M2 → providerID="synthetic", modelID="hf:MiniMaxAI/MiniMax-M2" chutes/moonshotai/Kimi-K2-Instruct-0905 → providerID="chutes", modelID="moonshotai/Kimi-K2-Instruct-0905" These models should resolve if they exist in provider.info.models. Additional Notes Works fine with a simple, single-segment model like opencode/grok-code. This looks like a parsing/normalization bug where --model is split on / and/or : and only the first segment is kept as modelID. If a : is treated as a provider separator elsewhere, it likely needs escaping or a different rule inside the model portion. Suggested Fix Adjust the --model parsing to: Treat the string as providerID + / + <modelID...>, where <modelID...> may include additional / segments and colons. Avoid splitting the <modelID...> on :; only the very first / should separate the provider from the rest. Add tests: synthetic/hf:MiniMaxAI/MiniMax-M2 → ["synthetic", "hf:MiniMaxAI/MiniMax-M2"] chutes/moonshotai/Kimi-K2-Instruct-0905 → ["chutes", "moonshotai/Kimi-K2-Instruct-0905"] Environment opencode version: opencode --version Node.js version: node -v OS: macOS/Linux/Windows (version/build) Shell: bash/zsh/pwsh Workarounds Tried Using a simpler model slug (works). Quoting the --model value (still reproduces). N/A otherwise. ### OpenCode version _No response_ ### Steps to reproduce _No response_ ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bug label 2026-02-16 17:36:33 -05:00
yindo closed this issue 2026-02-16 17:36:33 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Nov 6, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #749: Reports identical colon parsing bug in model identifiers causing crashes/failures with OpenRouter models containing ':' (like model:free suffix)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Nov 6, 2025): This issue might be a duplicate of existing issues. Please check: - #749: Reports identical colon parsing bug in model identifiers causing crashes/failures with OpenRouter models containing ':' (like model:free suffix) Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Nov 6, 2025):

fixed https://github.com/sst/opencode/commit/de1278414f4f11056649670f2e928631b267a74d

@rekram1-node commented on GitHub (Nov 6, 2025): fixed https://github.com/sst/opencode/commit/de1278414f4f11056649670f2e928631b267a74d
Author
Owner

@wojons commented on GitHub (Nov 6, 2025):

Sorry about that dont know why my auto upgrade was broken

@wojons commented on GitHub (Nov 6, 2025): Sorry about that dont know why my auto upgrade was broken
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2632