Repository navigation
Description
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
- Use the
claudeAgentprovider against an OpenRouter endpoint (any gateway that reports its model list through Claude Code's gateway discovery, withCLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1andANTHROPIC_BASE_URLpointing at it). - Let T3 probe the provider once so
~/.t3/caches/claudeAgent.jsonis written with the models that endpoint returns. - Change the model set behind that endpoint: remove a model, replace one model with another, or switch the endpoint's default model.
- 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:
shouldRetainMissingProviderModels()returnstrueunconditionally forclaudeAgent(the branch around line 239).mergeProviderModels()therefore returns the new list plus every previous non-custom model whose slug is not in it.ProviderRegistry.persistProviderwrites the merged snapshot tocaches/<instanceId>.json, andhydrateCachedProviderloads 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
hexwarrior6 commentedon Nov 26, 2026
Following up with a concrete fix proposal for the
claudeAgentretain, 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)endpointis the origin written into the snapshot byClaudeProvider.ts:833.shouldRetainMissingProviderModelstakes the previous provider as an optional argument, andmergeProviderModelsforwards it frommergeProviderSnapshot.What stays the same
statusiswarningorerrorRisk
If a terminal
claudeon 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,
warningretains.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.
2SinceJuly commentedon Nov 26, 2026
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.
2SinceJuly commentedon Nov 26, 2026
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.fix(server): Claude gateway drops models its endpoint stopped listing
Merge origin/main into fix/43603-claude-gateway-models