anomalyco / anomalyco/opencode
Recently-used model is picked even when config excludes its provider
@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
- Use a model from provider A at least once so it lands in the recent-models list (
model.jsonin opencode's state dir). - Change your config so
providercontains only provider B. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.