# Does every Claude auth mode report `init.models`?

- `@anthropic-ai/claude-agent-sdk` 0.3.321 types `SDKControlInitializeResponse.models` as a required
  `ModelInfo[]`.
- Claude Code 2.1.325's stdio `initialize` handler fills it from the model picker rows: the built-in
  lineup for the active API provider (firstParty, Bedrock, Vertex, Foundry, Mantle, gateway),
  `ANTHROPIC_CUSTOM_MODEL_OPTION`, settings and gateway-discovered rows, and server-provided rows
  for firstParty/gateway. Only the remote-bridge REPL ack and a parked-spare stub answer
  `models: []`; T3's stdio probe uses neither. (Read from the installed CLI bundle; no session started.)
- T3 side: Claude is `ready` only when `initialize` succeeded. The ready list always contains T3's
  catalog for the CLI version. `init.models` only adds models the catalog does not know (gateway
  models, Bedrock profiles, releases newer than the manifest, a custom model option). So the
  change can drop only those SDK-only rows, and only after the SDK stopped reporting them.
- A failed `initialize` reuses the last good capabilities once (still ready, same list); after
  that the snapshot is `warning`, which keeps the old models.


## Gateway model discovery (`CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY` + `ANTHROPIC_BASE_URL`)

Claude Code refreshes gateway models in the background after `initialize` (T3 keeps the probe
alive for the discovery timeout, `claudeGatewayDiscoveryGraceMs`). What `initialize` reports is
the on-disk cache `<claude config>/cache/gateway-models.json` (`{baseUrl, fetchedAt, models}`),
used only when its `baseUrl` matches the current `ANTHROPIC_BASE_URL`.

Discovery overwrites that file only after a successful `/v1/models` fetch with at least one usable
model. A non-OK status, a failed validation, zero models, a timeout or an exception all return
early and leave the cached list in place. So a transient gateway failure does not shrink
`init.models`: a ready probe reports the last list discovery succeeded with, which is also what
Claude Code's own `/model` picker shows.

But the cache holds one base URL per Claude home, and T3 Claude instances share `~/.claude`
unless a home path is set (apps/server/src/provider/Drivers/ClaudeHome.ts). Two instances on
different gateways (or the user's own terminal `claude` on another gateway) overwrite each other's
cache, so a ready probe can report none of its gateway models while the gateway still serves
them. With retention off, those models would flap out of the picker on most refreshes. A missing
cache file has the same effect until the next refresh.

Decision: Claude keeps retaining missing models (explicit exception in
`shouldRetainMissingProviderModels`). Dropping stale Claude models needs the driver to know when
its list is complete, which is a separate change.
