Skip to content

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

Description

@chaitanyarahalkar

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 @ 55b0211)

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions