[FEATURE]: Validate --model argument early with helpful error messages #6917

Open
opened 2026-02-16 18:05:35 -05:00 by yindo · 1 comment
Owner

Originally created by @zeromask1337 on GitHub (Jan 20, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

Currently opencode cli doesn't provide any helpfull messages if you mistyped model name, instead it just throws raw error. It also ignores such edgecase as empty string --model "" or --model " "

$ opencode run --model "anthropic/claude-sonet-4-5" "How pointers work in Go?"
1051 |     const provider = s.providers[providerID]
1052 |     if (!provider) {
1053 |       const availableProviders = Object.keys(s.providers)
1054 |       const matches = fuzzysort.go(providerID, availableProviders, { limit: 3, threshold: -10000 })
1055 |       const suggestions = matches.map((m) => m.target)
1056 |       throw new ModelNotFoundError({ providerID, modelID, suggestions })
                   ^
ProviderModelNotFoundError: ProviderModelNotFoundError
 data: {
  providerID: "anthropic",
  modelID: "claude-sonet-4-5",
  suggestions: [],
},

      at getModel (src/provider/provider.ts:1056:13)

I suggest using existing validation method, making cli error output much prettier and helping.

$ opencode run --model "anthropic/claude-sonet-4-5" "How numbers work?"
Model not found: anthropic/claude-sonet-4-5
Try: `opencode models` to list available models
Or check your config (opencode.json) provider/model names
Originally created by @zeromask1337 on GitHub (Jan 20, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request **Problem** Currently opencode cli doesn't provide any helpfull messages if you mistyped model name, instead it just throws raw error. It also ignores such edgecase as empty string `--model ""` or `--model " "` ```sh $ opencode run --model "anthropic/claude-sonet-4-5" "How pointers work in Go?" 1051 | const provider = s.providers[providerID] 1052 | if (!provider) { 1053 | const availableProviders = Object.keys(s.providers) 1054 | const matches = fuzzysort.go(providerID, availableProviders, { limit: 3, threshold: -10000 }) 1055 | const suggestions = matches.map((m) => m.target) 1056 | throw new ModelNotFoundError({ providerID, modelID, suggestions }) ^ ProviderModelNotFoundError: ProviderModelNotFoundError data: { providerID: "anthropic", modelID: "claude-sonet-4-5", suggestions: [], }, at getModel (src/provider/provider.ts:1056:13) ``` I suggest using existing validation method, making cli error output much prettier and helping. ```sh $ opencode run --model "anthropic/claude-sonet-4-5" "How numbers work?" Model not found: anthropic/claude-sonet-4-5 Try: `opencode models` to list available models Or check your config (opencode.json) provider/model names ```
yindo added the discussion label 2026-02-16 18:05:35 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2026):

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

  • #8460: API doesn't report invalid model errors via event stream - addresses error reporting when invalid models are used
  • #7958: ProviderModelNotFoundError for custom provider in GitHub Action - shows the same raw error being thrown without helpful context
  • #9203: Feature: Support disabled_models config to hide specific models - related to model validation and availability checking

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

@github-actions[bot] commented on GitHub (Jan 20, 2026): This issue might be a duplicate of existing issues. Please check: - #8460: API doesn't report invalid model errors via event stream - addresses error reporting when invalid models are used - #7958: ProviderModelNotFoundError for custom provider in GitHub Action - shows the same raw error being thrown without helpful context - #9203: Feature: Support disabled_models config to hide specific models - related to model validation and availability checking Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6917