[BUG] Using --prompt causes the wrong model to be selected.
Description
When you just run opencode, it launches with the default model which the user has selected. This is good.
But when you then run opencode --prompt "What is this repo?", instead of exactly the same behavior but with the prompt, it launches with Gemini 3 Pro via Github as the provider.
Adding --prompt has nothing to do with the model. So forcing this model which will often fail, is an undesirable and unrelated outcome that appears to be a bug.
Plugins
No response
OpenCode version
1.1.20
Steps to reproduce
opencode --prompt "What is this repo?"
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
This issue might be a duplicate of existing issues. Please check:
- #8452: Model selection in /command incorrectly changes the default model
Both issues appear to involve model selection being unintentionally changed when using different flags or commands (--prompt flag in this case, /command in #8452). The underlying cause may be related to how model defaults are handled when alternative invocation methods are used.
Feel free to ignore if this specific case differs from the linked issue.
To add to this, if you have "model", in your opencode.json, this bug doesn't appear. But if you don't and your default is the last selected model (most people are in this position), then the bug persists.
I believe there is a timing issue here where the prompt submits prior to the tui having last used model available