You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opencode-go: silent fallback to gpt-6-luna when requested model is rate-limited #56755
When calling opencode run --model opencode-go/<model> (also with --standalone), if the requested model returns a rate-limit error, the provider silently substitutes gpt-6-luna and returns a successful response. The CLI still prints > build · <requested-model>, so the caller cannot tell the wrong model ran. Usage/billing is attributed to gpt-6-luna.
This happens even when gpt-6-luna is disabled/removed from the user's opencode-go profile/model list.
Steps to reproduce
Run concurrent requests against opencode-go/longcat-2.5-preview-free (or opencode-go/beam-free) until rate-limited (429).
Observe the response still succeeds, but the account usage shows gpt-6-luna instead of the requested model.
Expected behavior
On rate limit, the request should fail with the rate-limit error (or retry), not silently serve a different model the user did not request and has disabled.
Environment
OpenCode CLI v2.0.29 (and Desktop 2.0.32)
macOS, opencode-go provider
Affected models observed: longcat-2.5-preview-free, beam-free (both fall back to gpt-6-luna)
Additional context
The CLI reports the requested model in its > build · <model> line, masking the substitution. There is no way for a caller to detect which model actually served the response.
Thanks for the detailed report! I think this is a duplicate of #52367. The extra gpt-6-luna usage most likely isn't a fallback from your requested model. It looks like OpenCode's separate background request that generates the session title.
If you don't set small_model, OpenCode picks a small model from the same provider to write the session title, and it prefers the gpt-luna family. On opencode-go that means gpt-6-luna for every new session, whichever model you chose (see Model.small in packages/core/src/model.ts). The main response still comes from the model shown in > build · <model>. After a 429, the request is usually retried, which is probably why it still succeeded.
A workaround is to set small_model in opencode.json to a model you want to use for titles, e.g.:
The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, if you can show that the main response itself came from gpt-6-luna, not just an extra small usage row per session, please reply with the details.
After reviewing the linked issues (#52004, #52367, #41697) and the code, the root cause is confirmed: Model.small in packages/core/src/model.ts hardcodes the gpt-luna family first and ignores cost/enabled state, so title generation bills gpt-6-luna even when free models exist or the model is disabled. The usage I saw was from the title agent, not a fallback from the requested model.
I've opened a PR that makes Model.small prefer free (zero-cost) models, then cheapest, and respect model.enabled: #56761
Workaround for affected users until merged: set small_model in opencode.json.
Thanks for checking, and for opening #56761! Since you've confirmed the extra usage came from title generation, I'll leave this closed as a duplicate of #52367. The fix is tracked in #52004, which your PR addresses.
One detail that may help with the PR: Model.small already skips models disabled in your local config. It searches value.available, which only keeps enabled models (packages/core/src/model.ts:226). Turning a model off in your Go account on the website doesn't change anything on the client, though. That's #41697, so the PR's enabled check probably won't help that case. Setting small_model in opencode.json remains the workaround.
We atleast need to make sure this is fixed on gateway. So that we only use models that are enabled.
Moreover by default it should use model from original invocation? It is difficult to trace where these calls are coming from otherwise.
The bug on gateway shall be resolved & there should be a new feature allowing us to select what we use for title generation to not give a shocker.
Choosing the title model: you can already do this. Set small_model in opencode.json, e.g. "small_model": "opencode-go/longcat-2.5-preview-free". In v2 this sets the model the title agent uses, so you won't get unexpected gpt-6-luna charges.
Keeping the discussion in those issues makes it easier for maintainers to follow, so this one will still be closed as a duplicate of #52367.
Thanks for following up. As you found, the extra usage was from title generation rather than a fallback; OpenCode retries the same model on rate limits and never switches models. Title model selection is tracked in #52004, so we're closing this.
Until those are resolved, setting small_model in opencode.json controls which model generates titles. Thanks for digging into this and for opening the PR!
Activity
opencode-agent commentedon Oct 18, 2026
Thanks for the detailed report! I think this is a duplicate of #52367. The extra
gpt-6-lunausage most likely isn't a fallback from your requested model. It looks like OpenCode's separate background request that generates the session title.If you don't set
small_model, OpenCode picks a small model from the same provider to write the session title, and it prefers thegpt-lunafamily. Onopencode-gothat meansgpt-6-lunafor every new session, whichever model you chose (seeModel.smallinpackages/core/src/model.ts). The main response still comes from the model shown in> build · <model>. After a 429, the request is usually retried, which is probably why it still succeeded.A workaround is to set
small_modelinopencode.jsonto a model you want to use for titles, e.g.:{ "small_model": "opencode-go/longcat-2.5-preview-free" }Possible duplicates and related issues, ordered from most to least likely:
gpt-6-lunausage shows up next to longcat or space-bunny free model usage, traced to title generationgpt-6-lunaon opencode-goThe bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different. For example, if you can show that the main response itself came from
gpt-6-luna, not just an extra small usage row per session, please reply with the details.r-icks commentedon Oct 18, 2026
After reviewing the linked issues (#52004, #52367, #41697) and the code, the root cause is confirmed:
Model.smallinpackages/core/src/model.tshardcodes thegpt-lunafamily first and ignores cost/enabled state, so title generation billsgpt-6-lunaeven when free models exist or the model is disabled. The usage I saw was from the title agent, not a fallback from the requested model.I've opened a PR that makes
Model.smallprefer free (zero-cost) models, then cheapest, and respectmodel.enabled: #56761Workaround for affected users until merged: set
small_modelinopencode.json.opencode-agent commentedon Oct 18, 2026
Thanks for checking, and for opening #56761! Since you've confirmed the extra usage came from title generation, I'll leave this closed as a duplicate of #52367. The fix is tracked in #52004, which your PR addresses.
One detail that may help with the PR:
Model.smallalready skips models disabled in your local config. It searchesvalue.available, which only keeps enabled models (packages/core/src/model.ts:226). Turning a model off in your Go account on the website doesn't change anything on the client, though. That's #41697, so the PR'senabledcheck probably won't help that case. Settingsmall_modelinopencode.jsonremains the workaround.r-icks commentedon Oct 18, 2026
We atleast need to make sure this is fixed on gateway. So that we only use models that are enabled.
Moreover by default it should use model from original invocation? It is difficult to trace where these calls are coming from otherwise.
The bug on gateway shall be resolved & there should be a new feature allowing us to select what we use for title generation to not give a shocker.
opencode-agent commentedon Oct 18, 2026
Thanks, these are fair points. Each one already has an issue or setting, so I'll keep this closed as a duplicate:
GET /api/agentshowsmodel: nullfor the title agent). Your suggestion is a good addition there, alongside your PR fix(model): make Model.small prefer free/cheap models and respect enabled state #56761.small_modelinopencode.json, e.g."small_model": "opencode-go/longcat-2.5-preview-free". In v2 this sets the model the title agent uses, so you won't get unexpectedgpt-6-lunacharges.Keeping the discussion in those issues makes it easier for maintainers to follow, so this one will still be closed as a duplicate of #52367.
opencode-agent commentedon Oct 18, 2026
Thanks for following up. As you found, the extra usage was from title generation rather than a fallback; OpenCode retries the same model on rate limits and never switches models. Title model selection is tracked in #52004, so we're closing this.
opencode-agent commentedon Oct 19, 2026
Closing this as a duplicate of #52367. As you found, the
gpt-6-lunausage came from session title generation, not a fallback after a rate limit.Follow-ups are tracked here:
Until those are resolved, setting
small_modelinopencode.jsoncontrols which model generates titles. Thanks for digging into this and for opening the PR!