Repository navigation
fix(server): Claude gateway drops models its endpoint stopped listing - #43619
2SinceJuly wants to merge 6 commits into
Conversation
shouldRetainMissingProviderModels kept every missing model for claudeAgent, so a gateway that removed a model left its slug in caches/claudeAgent.json forever: every refresh merged it back and hydrateCachedProvider restored it at boot. Treat a ready probe from the instance's own unchanged customEndpoint as authoritative, and keep retaining when the endpoint changed, the probe is not ready, or the instance has no endpoint. Fixes pingdotgg#43603
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
shouldRetainMissingProviderModels kept every missing model for claudeAgent, so a gateway that removed a model left its slug in caches/claudeAgent.json forever: every refresh merged it back and hydrateCachedProvider restored it at boot. Treat a ready probe from the instance's own unchanged customEndpoint as authoritative, and keep retaining when the endpoint changed, the probe is not ready, or the instance has no endpoint. Fixes pingdotgg#43603
Read the endpoint from both snapshots inline instead of a helper, take the previous snapshot as required (mergeProviderSnapshot always has one), and drop the cache round-trip test: persistence is shared plumbing and the merge test already fails without the fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The persist round-trip test it edits was removed in the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EvidenceEvidence: Linux web app, Chromium, light theme, 1280×800 CSS viewport, real Claude Code 2.1.332, separate fresh databases. List two gateway models, confirm both in the picker, remove opus from the unchanged endpoint, complete two provider refreshes, reopen the picker, then fully restart the app and check again. Two refreshes allow Claude's asynchronous gateway cache update to reach the next initialization.
Gateway script · Reproduction instructions Not shown:
|
Main fixed pingdotgg#43603 in pingdotgg#43624 (Claude probes without gateway models are marked modelsIncomplete and only those keep missing models), so both conflicting files take main's side and this branch no longer differs from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for this. Main has the change since #43624. Main now removes models omitted by a completed Claude gateway discovery while preserving models when discovery is incomplete; I compared the PR’s commits and current head against the merged fix, and its latest merge takes main’s implementation with zero changed files remaining. Closing as superseded. |


Problem
A
claudeAgentinstance pointing at a custom gateway keeps offering models the gateway stopped returning.~/.t3/caches/claudeAgent.jsonstill holds them after a relaunch, and every refresh writes them back. Closes #43603.Steps from the issue:
claudeAgentat a gateway (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1,ANTHROPIC_BASE_URL), let T3 probe once./v1/models.Change
shouldRetainMissingProviderModelsreturnedtrueunconditionally forclaudeAgent, somergeProviderModelsappended every previous non-custom slug the new list omitted, andpersistProviderwrote that merged snapshot back.hydrateCachedProviderthen loaded it at boot, so the stale slugs outlived restarts.The retain exists because Claude Code keeps one gateway model cache per Claude home and a probe can describe a different gateway after a terminal
claudeor another instance rewrote it. This keeps that protection and narrows it:claudeAgentnow retains only when a ready probe may not describe this instance's gateway — no custom endpoint, the endpoint changed since the previous snapshot, the probe is notready, or the instance is not installed. A ready probe from an unchanged custom endpoint is authoritative, so the slugs it omits drop out. The same change fixes the display, because the picker reads the same merged snapshot.shouldRetainMissingProviderModelsandmergeProviderModelsnow take the previous provider, whichmergeProviderSnapshotalready has.Scope
Bug fix for #43603. One problem, one driver.
kirokeeps retaining unconditionally (its probe legitimately falls back to a built-in list), andpi/acpRegistry/antigravity/codex/opencodeare untouched. Installations without a custom endpoint, which is most of them, behave exactly as before.Tradeoff kept from the issue: if a terminal
claudeon a different gateway rewrites the CLI cache right before T3 probes, a same-endpoint probe is read 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 the permanent staleness this fixes.Verification
Two tests in
apps/server/src/provider/ProviderRegistry.test.ts, run withvp test run src/provider/ProviderRegistry.test.tsinapps/server.drops claudeAgent models a ready probe from the same gateway stopped listing— merges a two-model snapshot with a ready probe that lists one. Same endpoint dropsopenai/gpt-5; a changed endpoint, awarningprobe, and an instance with noendpointall keep it.persists claudeAgent gateway removals so they survive a restart— writes the two-model snapshot to the status cache, boots the registry, refreshes with the one-model probe, and asserts both the returned snapshot and the rewritten cache hold onlyanthropic/claude-sonnet-4.5. Runs the in-process and restart paths.Results, with the source change stashed and restored:
expected [ 'anthropic/claude-sonnet-4.5', …(1) ] to deeply equal [ 'anthropic/claude-sonnet-4.5' ]and+ "openai/gpt-5"in the diff; the second on the cache contents.pnpm typechecksucceeds (43/43).pnpm lintreports no errors in the changed files.Not checked: I did not attach a live custom endpoint and watch
~/.t3/caches/claudeAgent.jsonchange in a running app; the evidence above is at the registry and cache layer the issue points at. Runningapps/server/src/provider/as a directory shows 3 failures (AntigravityInstallationLinux page size, twoClaudeSkillsplugin-registryEEXIST) that reproduce without this change and are unrelated.Model: Claude Code. The reproduction, root cause, and proposed fix came from the issue author; I wrote the implementation, tests, and verification here.