Skip to content

fix(server): Claude gateway drops models its endpoint stopped listing - #43619

Closed
2SinceJuly wants to merge 6 commits into
pingdotgg:mainfrom
2SinceJuly:fix/43603-claude-gateway-models
Closed

2SinceJuly wants to merge 6 commits into
pingdotgg:mainfrom
2SinceJuly:fix/43603-claude-gateway-models

Conversation

@2SinceJuly

Copy link
Copy Markdown
Contributor

Problem

A claudeAgent instance pointing at a custom gateway keeps offering models the gateway stopped returning. ~/.t3/caches/claudeAgent.json still holds them after a relaunch, and every refresh writes them back. Closes #43603.

Steps from the issue:

  1. Point claudeAgent at a gateway (CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1, ANTHROPIC_BASE_URL), let T3 probe once.
  2. Remove a model from that endpoint's /v1/models.
  3. Relaunch and open the model picker: the removed slug is still there.

Change

shouldRetainMissingProviderModels returned true unconditionally for claudeAgent, so mergeProviderModels appended every previous non-custom slug the new list omitted, and persistProvider wrote that merged snapshot back. hydrateCachedProvider then 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 claude or another instance rewrote it. This keeps that protection and narrows it: claudeAgent now 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 not ready, 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.

shouldRetainMissingProviderModels and mergeProviderModels now take the previous provider, which mergeProviderSnapshot already has.

Scope

Bug fix for #43603. One problem, one driver. kiro keeps retaining unconditionally (its probe legitimately falls back to a built-in list), and pi/acpRegistry/antigravity/codex/opencode are untouched. Installations without a custom endpoint, which is most of them, behave exactly as before.

Tradeoff kept from the issue: if a terminal claude on 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 with vp test run src/provider/ProviderRegistry.test.ts in apps/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 drops openai/gpt-5; a changed endpoint, a warning probe, and an instance with no endpoint all 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 only anthropic/claude-sonnet-4.5. Runs the in-process and restart paths.

Results, with the source change stashed and restored:

  • Unfixed source: both tests fail. The first with 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.
  • Fixed source: 98/98 in the file pass.

pnpm typecheck succeeds (43/43). pnpm lint reports no errors in the changed files.

Not checked: I did not attach a live custom endpoint and watch ~/.t3/caches/claudeAgent.json change in a running app; the evidence above is at the registry and cache layer the issue points at. Running apps/server/src/provider/ as a directory shows 3 failures (AntigravityInstallation Linux page size, two ClaudeSkills plugin-registry EEXIST) 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.

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
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 26, 2026
@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The provider registry now uses both snapshots to decide whether to retain missing models and OpenCode metadata. For Claude Agent, a ready, installed provider drops omitted models when the custom endpoint matches the previous snapshot.

Changes: Claude Agent model refresh

Layer / File(s) Summary
Snapshot-aware model merging
apps/server/src/provider/ProviderRegistry.ts, apps/server/src/provider/ProviderRegistry.test.ts
The registry compares previous and incoming snapshots when deciding whether to retain missing models and OpenCode metadata. For Claude Agent, omitted models are dropped when the provider is installed and ready and both snapshots use the same custom endpoint. Tests cover changed or absent endpoints and warning status.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: sharad-patel1, juliusmarminge

Merge Risk: Minimal · previous review ccb43

Claude Agent models that a custom gateway no longer lists are now dropped from the picker when the same gateway's probe is ready. Models are still retained when the endpoint changed, the probe is not ready, or no endpoint is known. No blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a fix in the server that stops the Claude gateway from keeping models its endpoint no longer lists. The raw summary, objectives, and description all describe this same…
Description check Passed The description follows the template. It has Problem, Change, Scope, and Verification sections, and each one is filled in with specific detail. The Problem section gives reproduction steps and links i…
Linked Issues check Passed Directly linked issue #43603 requires that the claudeAgent picker and cache stop offering models a custom gateway no longer lists, while keeping protection against probes that may describe another gat…
Out of Scope Changes check Passed The whole-PR source diff in ProviderRegistry.ts is limited to the claudeAgent retain decision and the helper plumbing needed for it. The previousProvider parameter is added to shouldRetainMissingProvi…
Full details: Title check

Explanation

The title names the main change: a fix in the server that stops the Claude gateway from keeping models its endpoint no longer lists. The raw summary, objectives, and description all describe this same change in shouldRetainMissingProviderModels and mergeProviderSnapshot. The title is specific and follows the conventional commit form, though it is 69 characters and slightly long.

Full details: Description check

Explanation

The description follows the template. It has Problem, Change, Scope, and Verification sections, and each one is filled in with specific detail. The Problem section gives reproduction steps and links issue #43603. The Change section explains the root cause and the narrowed retention rule. The Scope section limits the fix to claudeAgent and explains why it needs no other changes. The Verification section lists the exact tests, the commands, and the before and after results, and it states what was not checked. The description also names the model and harness, as the template asks. The template's 'If you used an agent' line is covered by the Model line.

Full details: Linked Issues check

Explanation

Directly linked issue #43603 requires that the claudeAgent picker and cache stop offering models a custom gateway no longer lists, while keeping protection against probes that may describe another gateway. The whole-PR diff (mergeBase to head) of apps/server/src/provider/ProviderRegistry.ts shows the claudeAgent branch of shouldRetainMissingProviderModels now returns false only when all of these hold: the probe endpoint is defined, it equals the previous snapshot's customEndpoint, the provider is installed, and its status is ready. Otherwise it retains. mergeProviderModels receives previousProvider, so a ready same-endpoint probe no longer appends omitted slugs. mergeProviderSnapshot feeds that merged result to persistProvider, and hydrateCachedProvider reloads it, so stale slugs also leave the cache. This matches the issue's first proposed option. Gaps: the issue describes a 'ready, non-empty' probe, but the code does not require a non-empty list; an empty ready probe from the same endpoint drops all retained models. The issue's wording on this point is 'for example', and the empty case matches the reported 'currently returned' expectation, so this is noted rather than failed. The test file diff could not be read through the diff operation. The objectives say the cache round-trip test was dropped in the second commit, while the PR description says it runs, so restart-path test coverage is not independently confirmed. No live gateway run was performed.

Full details: Out of Scope Changes check

Explanation

The whole-PR source diff in ProviderRegistry.ts is limited to the claudeAgent retain decision and the helper plumbing needed for it. The previousProvider parameter is added to shouldRetainMissingProviderModels, shouldRetainMissingOpenCodeMetadata, and mergeProviderModels, and the call sites pass previousProvider. The opencode metadata path calls the same helper and keeps its prior behavior because its branch is unchanged. The kiro, pi, acpRegistry, antigravity, and codex branches keep their conditions. The change to mergeProviderModels' signature is a refactor needed by the new retain decision. No unrelated source change was found. The test file was not read directly, so its scope rests on the PR description and summary, which describe claudeAgent gateway tests.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between df6091a and ccb43e4.

Files selected for processing: 2

  • apps/server/src/provider/ProviderRegistry.test.ts
  • apps/server/src/provider/ProviderRegistry.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

juliusmarminge and others added 4 commits November 26, 2026 16:31
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>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Evidence: 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.

Before After
Before: removed model survives restart After: removed model remains absent
8c6a4a578b ccb43e4ecf
Refresh recording · Restart recording Refresh recording · Restart recording

Gateway script · Reproduction instructions

Not shown:

  • Single-refresh immediacy was not demonstrated: this Claude version initializes from its previous gateway cache and refreshes that cache asynchronously. The verified sequence used two completed refreshes on both commits.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 26, 2026
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>
@juliusmarminge

Copy link
Copy Markdown
Member

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.

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). takeover:ready Takeover done; auto-lands when gates pass vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants