opencode run unexpectedly always picks claude-sonnet-4 if you don't specify a model #1616

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

Originally created by @astrolox on GitHub (Sep 5, 2025).

Originally assigned to: @rekram1-node on GitHub.

Bug

When I use opencode run (CLI mode, not TUI mode).
It automatically selects claude-sonnet-4.
I expected it to select gpt-4.1 because that's what is shown in the TUI as the selected model.
This is done completely silently, I was unaware until I received the budget usage notification from my provider.

opencode --print-logs --log-level INFO run "Which model are you?" 2>&1 | grep -ie provider | head -n 7

INFO  2025-09-05T16:01:11 +3ms service=provider init
INFO  2025-09-05T16:01:11 +2ms service=provider providerID=github-copilot found
INFO  2025-09-05T16:01:11 +0ms service=provider providerID=github-models found
INFO  2025-09-05T16:01:11 +0ms service=provider providerID=opencode found
INFO  2025-09-05T16:01:11 +0ms service=provider providerID=github-copilot modelID=claude-sonnet-4 getModel
INFO  2025-09-05T16:01:11 +1ms service=provider status=started providerID=github-copilot getSDK
INFO  2025-09-05T16:01:11 +73ms service=provider status=completed duration=73 providerID=github-copilot getSDK

Suggested Fix

Use the same logic for provider and model selection for both the TUI and the CLI. That way the behaviour will be consistent and less surprising to users.

Notes

  • Setting a default model in the configuration file works correctly.

  • Specifying the model via the -m cli parameter also works correctly.

  • It does not pick the most recently used model

  • It does not look for the first model with some config (I read somewhere that it should do that, but I can't find that info again)

Background

I've been using opencode with the TUI, and have been using the GitHub Copilot GPT-4.1 model.
When I run opencode this is the model which is selected (based on the fact that it was the one I used previously). By the way where (on disk) is that stored?

In my configuration file at ~/.config/opencode/opencode.json.

  • I do not have a default model
  • I do have a provider section, and github-copilot, gpt-4.1 is the only entry.

I wanted to start scripting opencode, so I started using opencode run.
Everything seemed ok until GitHub told me that I'd used 200% of my Premium Requests budget after a few hours 😲
Thankfully I have a budget enabled to prevent actually over spending; I hate to think what the bill would be if that was not enabled.

Related documentation

Originally created by @astrolox on GitHub (Sep 5, 2025). Originally assigned to: @rekram1-node on GitHub. ## Bug When I use `opencode run` (CLI mode, not TUI mode). It automatically selects `claude-sonnet-4`. I expected it to select `gpt-4.1` because that's what is shown in the TUI as the selected model. This is done completely silently, I was unaware until I received the budget usage notification from my provider. ``` opencode --print-logs --log-level INFO run "Which model are you?" 2>&1 | grep -ie provider | head -n 7 INFO 2025-09-05T16:01:11 +3ms service=provider init INFO 2025-09-05T16:01:11 +2ms service=provider providerID=github-copilot found INFO 2025-09-05T16:01:11 +0ms service=provider providerID=github-models found INFO 2025-09-05T16:01:11 +0ms service=provider providerID=opencode found INFO 2025-09-05T16:01:11 +0ms service=provider providerID=github-copilot modelID=claude-sonnet-4 getModel INFO 2025-09-05T16:01:11 +1ms service=provider status=started providerID=github-copilot getSDK INFO 2025-09-05T16:01:11 +73ms service=provider status=completed duration=73 providerID=github-copilot getSDK ``` ## Suggested Fix Use the same logic for provider and model selection for both the TUI and the CLI. That way the behaviour will be consistent and less surprising to users. ## Notes - Setting a default model in the configuration file works correctly. - Specifying the model via the `-m` cli parameter also works correctly. - It does not pick the most recently used model - It does not look for the first model with some config _(I read somewhere that it should do that, but I can't find that info again)_ ## Background I've been using `opencode` with the TUI, and have been using the `GitHub Copilot GPT-4.1` model. When I run `opencode` this is the model which is selected (based on the fact that it was the one I used previously). _By the way where (on disk) is that stored?_ In my configuration file at `~/.config/opencode/opencode.json`. - I do not have a default model - I do have a provider section, and `github-copilot`, `gpt-4.1` is the only entry. I wanted to start scripting opencode, so I started using `opencode run`. Everything seemed ok until GitHub told me that I'd used 200% of my Premium Requests budget after a few hours 😲 Thankfully I have a budget enabled to prevent actually over spending; I hate to think what the bill would be if that was not enabled. ## Related documentation - https://opencode.ai/docs/models/#loading-models - https://docs.github.com/en/copilot/concepts/billing/copilot-requests - https://docs.github.com/en/billing/tutorials/set-up-budgets
yindo closed this issue 2026-02-16 17:31:46 -05:00
Author
Owner

@rekram1-node commented on GitHub (Sep 5, 2025):

will fix

@rekram1-node commented on GitHub (Sep 5, 2025): will fix
Author
Owner

@rekram1-node commented on GitHub (Sep 5, 2025):

will be fixed in next release

@rekram1-node commented on GitHub (Sep 5, 2025): will be fixed in next release
Author
Owner

@flownext1 commented on GitHub (Jan 29, 2026):

still broken

@flownext1 commented on GitHub (Jan 29, 2026): still broken
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1616