anomalyco / anomalyco/opencode

Recently-used model is picked even when config excludes its provider

Open
#39,191 0 comments 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Jul 27, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

If you have used a model from one provider and later change your config to declare only a different provider, opencode keeps starting sessions on the old model. I hit this moving from Anthropic to a local OpenAI-compatible endpoint: my config lists only the local provider, but new sessions still came up on claude-sonnet-4-5.

In defaultModel (packages/opencode/src/provider/provider.ts) the recently-used list is walked before Object.keys(cfg.provider) is computed, and the loop never consults it. The configured-provider allowlist only gates the fallback path below the loop, so anything in the recent list wins regardless of what the config says.

OpenCode version

1.18.7 (reproduced on dev @ 55b0211690)

Steps to reproduce
  1. Use a model from provider A at least once so it lands in the recent-models list (model.json in opencode's state dir).
  2. Change your config so provider contains only provider B.
  3. Start a new session without -m.

Expected: a model from provider B. Actual: the provider A model from step 1.

Operating System

macOS 26.5.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.