Skip to content

[Bug]: Claude provider keeps offering models its gateway no longer lists #43603

Done

Description

@hexwarrior6

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Use the claudeAgent provider against an OpenRouter endpoint (any gateway that reports its model list through Claude Code's gateway discovery, with CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 and ANTHROPIC_BASE_URL pointing at it).
  2. Let T3 probe the provider once so ~/.t3/caches/claudeAgent.json is written with the models that endpoint returns.
  3. Change the model set behind that endpoint: remove a model, replace one model with another, or switch the endpoint's default model.
  4. Quit and relaunch T3, then open the model picker (Settings → Providers → "Refresh provider status" shows the same result).

Expected behavior

The picker lists the models the endpoint currently returns. A model the endpoint stopped returning disappears.

Actual behavior

The old slugs stay forever. ~/.t3/caches/claudeAgent.json still contains them after a relaunch, and every refresh writes them back. The only way to clear them is to quit T3, delete ~/.t3/caches/claudeAgent.json, and relaunch. The stale entries then disappear — until the model set changes again.

This is not tied to any particular model ID format. Any slug the new list omits is appended back into the merged snapshot, so swapping models at the endpoint leaves the previous ones in the picker next to the new ones.

Logs or stack traces

After deleting ~/.t3/caches/claudeAgent.json and relaunching, the cache held only the models the endpoint actually returned. Before the cleanup it also held models the endpoint no longer listed:

{
  "models": [
    { "slug": "anthropic/claude-sonnet-4.5", "name": "Anthropic: Claude Sonnet 4.5" },
    { "slug": "openai/gpt-5", "name": "OpenAI: GPT-5" }
  ]
}

The second entry was absent from the endpoint's /v1/models response, yet it stayed in the picker across relaunches and provider refreshes.

Impact

Minor bug or occasional failure

Version or commit

0.1.13-nightly.20261125.5258, also reproduced on main @ 8468c7af6

Environment

macOS 14, desktop app, claudeAgent provider with a custom endpoint (auth.type: customEndpoint), Claude Code CLI 2.1.332

Root cause

apps/server/src/provider/ProviderRegistry.ts:

  1. shouldRetainMissingProviderModels() returns true unconditionally for claudeAgent (the branch around line 239).
  2. mergeProviderModels() therefore returns the new list plus every previous non-custom model whose slug is not in it.
  3. ProviderRegistry.persistProvider writes the merged snapshot to caches/<instanceId>.json, and hydrateCachedProvider loads it back at boot. The stale slugs outlive both restarts and refreshes.

This is the same class of bug that was fixed for other drivers by treating a completed catalog read as authoritative: Cursor (#28018), fx/Muse (#37457), OpenCode (#41626).

Proposed fix

The claudeAgent retain is there for a real case: Claude Code keeps one gateway model cache per Claude home, holding one base URL at a time, so a ready probe can omit this instance's gateway models after another instance or a terminal claude on a different gateway rewrote that cache. Dropping the retain outright would regress that.

Two options that keep the protection:

  • Treat a ready, non-empty probe as authoritative when it is known to describe the same gateway as the previous snapshot (for example when the provider's endpoint did not change), and retain only otherwise.
  • Otherwise age out retained slugs: if no ready probe has listed a slug for N consecutive checks (or N days), stop offering it.

I'm happy to open a PR for whichever direction you prefer.

Workaround

Quit T3, delete ~/.t3/caches/claudeAgent.json, relaunch. Or hide the stale entries in providerModelPreferences.claudeAgent.hiddenModels.

Activity

  1. hexwarrior6 commented on Nov 26, 2026

    @hexwarrior6
    Author

    Following up with a concrete fix proposal for the claudeAgent retain, in case it helps you decide.

    Idea

    The retain exists because Claude Code's gateway model cache is shared per Claude home and holds one base URL at a time, so a probe can describe a gateway other than this instance's. Keep that protection, but narrow it to the case where the probe may not describe this instance's gateway. When the endpoint did not change, a completed list is authoritative.

    Change (apps/server/src/provider/ProviderRegistry.ts)

    const isSameClaudeGateway = (
      previous: ServerProvider | undefined,
      next: ServerProvider,
    ): boolean =>
      previous !== undefined &&
      previous.driver === ProviderDriverKind.make("claudeAgent") &&
      previous.auth.type === "customEndpoint" &&
      next.auth.type === "customEndpoint" &&
      previous.auth.endpoint !== undefined &&
      previous.auth.endpoint === next.auth.endpoint;

    endpoint is the origin written into the snapshot by ClaudeProvider.ts:833.

    if (provider.driver === ProviderDriverKind.make("claudeAgent")) {
      return !(
        isSameClaudeGateway(previous, provider) &&
        provider.installed &&
        provider.status === "ready"
      );
    }

    shouldRetainMissingProviderModels takes the previous provider as an optional argument, and mergeProviderModels forwards it from mergeProviderSnapshot.

    What stays the same

    Case Result
    Different endpoint retain
    status is warning or error retain
    Probe returns no models retain (early return)
    Same endpoint, ready, fewer models drop the missing slugs

    Risk

    If a terminal claude on a different gateway rewrites the CLI cache right before T3 probes, the same-endpoint probe is misread as authoritative and those models disappear until a later probe lists them again. They come back as reported models, so it is short-lived churn rather than permanent staleness.

    Tests

    Three cases next to the ones added for the Cursor fix in #28018: same endpoint drops, changed endpoint retains, warning retains.

    Happy to open a PR in this shape if it matches your direction.

    On process: I don't know whether you prefer to settle the direction here before a PR exists, or to review a small bug-fix PR directly. Either works for me — I can wait for a signal on this issue, or open the PR now and link it here, whichever you prefer.

  2. 2SinceJuly commented on Nov 26, 2026

    @2SinceJuly
    Contributor

    I'm on it. Going with the narrower option: retain only when the probe may not describe this instance's gateway, so a ready probe from the same endpoint is authoritative.

  3. 2SinceJuly commented on Nov 26, 2026

    @2SinceJuly
    Contributor

    Opened #43619 with the narrower option: a ready probe from an unchanged custom endpoint is authoritative, and the retain stays for a changed endpoint, a non-ready probe, or an instance with no endpoint. Tests cover the merge and a restart round-trip through caches/<instanceId>.json.

  4. added a commit that references this issue on Nov 26, 2026
    2e92b1f
  5. added a commit that references this issue on Nov 26, 2026
    4d639eb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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