Skip to content

opencode-go: silent fallback to gpt-6-luna when requested model is rate-limited #56755

Closed as duplicate

Description

@r-icks

Description

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

  1. Run concurrent requests against opencode-go/longcat-2.5-preview-free (or opencode-go/beam-free) until rate-limited (429).
  2. 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.

Activity

  1. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    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.:

    {
      "small_model": "opencode-go/longcat-2.5-preview-free"
    }

    Possible duplicates and related issues, ordered from most to least likely:

    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.

  2. r-icks commented on Oct 18, 2026

    @r-icks
    Author

    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.

  3. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    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.

  4. r-icks commented on Oct 18, 2026

    @r-icks
    Author

    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.

  5. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    Thanks, these are fair points. Each one already has an issue or setting, so I'll keep this closed as a duplicate:

    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.

  6. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    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.

  7. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    Closing this as a duplicate of #52367. As you found, the gpt-6-luna usage came from session title generation, not a fallback after a rate limit.

    Follow-ups are tracked here:

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions