Skip to content

Stale per-directory provider state after external auth.json change: ProviderModelNotFoundError with misleading "Did you mean" until POST /global/dispose #50647

Closed as not planned

Description

@marcelrsoub

Summary

Provider state is cached per directory (InstanceState.make in provider.ts) and built once from Auth.all() at first use. auth.json is re-read live by the Auth service, but nothing watches the file — when it changes on disk from another process (TUI/CLI login, manual edit), already-cached directories keep the old snapshot. Prompts in those directories then fail with:

ProviderModelNotFoundError: Model not found: opencode-go/glm-5.3-flash. Did you mean: glm-5.3-flash?

The Did you mean suggestion is misleading: it comes from the models.dev catalog (which has the model), while the actual failure is that s.providers["opencode-go"] was never merged into that instance's state because the auth entry didn't exist when the state was built (mergeProvider: const match = database[providerID]; if (!match) return / auth loop skipped).

Directories first used after the auth change work fine — so it looks like a per-project/model problem when it's really cache staleness. POST /global/dispose fixes it immediately.

Found while debugging getpaseo/paseo#1925 (same error surfaced through Paseo).

Repro

  1. Start a server: opencode serve --port 4599
  2. Use directory A (builds its provider state), e.g.:
    curl -s -X POST "http://localhost:4599/session?directory=/tmp/dirA" -d '{}' -H 'Content-Type: application/json'
    curl -s -X POST "http://localhost:4599/session/$SID/prompt_async?directory=/tmp/dirA" \
      -H 'Content-Type: application/json' \
      -d '{"model":{"providerID":"<provider>","modelID":"<model>"},"parts":[{"type":"text","text":"hi"}]}'
  3. From another process, add that provider's key to ~/.local/share/opencode/auth.json (e.g. opencode auth login, or insert "<provider>": {"type": "api", "key": "..."} manually).
  4. Repeat step 2 with the same directory A → ProviderModelNotFoundError with a Did you mean: <exact model> suggestion.
  5. Same prompt in a fresh directory B (first use after the change) → works.
  6. curl -X POST http://localhost:4599/global/dispose → directory A works again.

Expected behavior

Auth changes should be visible to running servers: watching auth.json and calling disposeAllInstances (the path already used by PUT /global/config when changed) would fix it, or provider state should re-merge auth on read.

Environment

  • opencode:1.18.29 (long-running opencode serve process; installed CLI now1.18.32 — same code at v1.18.29 and dev)
  • OS: macOS (darwin)
  • Provider: opencode-go (key present in auth.json; opencode models lists the model)

Notes

Activity

  1. github-actions commented on Sep 22, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  2. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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

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