Discover Claude models from SDK initialization#4477
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review ... You can customize Macroscope's approvability policy. Learn more. |
e31cf53 to
734164f
Compare
A Claude capabilities probe failure degrades the snapshot to `warning` while still shipping the complete static fallback inventory, so treating it as a partial probe failure unioned the fallback catalog with the previously discovered SDK slugs and showed duplicate picker entries. Only a hard `error` (CLI missing or unrunnable) now retains stale models. Also map the SDK's `supportsAdaptiveThinking` to the `thinking` toggle for discovered models without effort levels, which otherwise lost the control the static catalog gave them. Co-Authored-By: Claude <noreply@anthropic.com>
734164f to
fc3bf5d
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit fc3bf5d. Configure here.
cd20057 to
fc3bf5d
Compare
| const findDescriptor = (id: string) => descriptors.find((descriptor) => descriptor.id === id); | ||
| const rawEffortSelection = getModelSelectionStringOptionValue(modelSelection, "effort"); | ||
| const resolvedEffort = resolveClaudeEffort(caps, rawEffortSelection); | ||
| const hasCatalogCapabilities = descriptors.length > 0; |
There was a problem hiding this comment.
🟡 Medium textGeneration/ClaudeTextGeneration.ts:137
When a model slug returned by live SDK discovery also exists in FALLBACK_CLAUDE_MODELS, hasCatalogCapabilities becomes true even though the descriptors came from the stale fallback list rather than the live catalog. Any option the live SDK advertises for that slug that is missing from the fallback descriptors — e.g. fastMode, or a new effort value — is resolved to undefined and silently dropped from the CLI invocation; the descriptors.length > 0 check only proves a fallback entry matched, not that the live capabilities were used. The fallback-vs-live decision should be driven by the selected model's live capability source, not by whether its slug collides with the fallback catalog.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/textGeneration/ClaudeTextGeneration.ts around line 137:
When a model slug returned by live SDK discovery also exists in `FALLBACK_CLAUDE_MODELS`, `hasCatalogCapabilities` becomes `true` even though the descriptors came from the stale fallback list rather than the live catalog. Any option the live SDK advertises for that slug that is missing from the fallback descriptors — e.g. `fastMode`, or a new effort value — is resolved to `undefined` and silently dropped from the CLI invocation; the `descriptors.length > 0` check only proves a fallback entry matched, not that the live capabilities were used. The fallback-vs-live decision should be driven by the selected model's live capability source, not by whether its slug collides with the fallback catalog.

What Changed
Why
Claude Code already exposes its current, account-aware model inventory through
initializationResult(). Maintaining a second primary catalog in T3 Code goes stale when Claude adds models or aliases, which is why current Opus 5-backed entries were missing from the picker.UI Changes
No component or layout changes. The model picker now mirrors the live Claude CLI inventory; an isolated app verification showed
Default (recommended),Opus (1M context),Fable,Sonnet, andHaiku, with the discovered Opus reasoning levels and Fast Mode available.Checklist
vp check(0 errors; 11 unrelated existing warnings)vp run typecheckvp test run apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts apps/server/src/provider/Layers/ProviderRegistry.test.ts apps/server/src/provider/Layers/ClaudeAdapter.test.ts apps/server/src/textGeneration/ClaudeTextGeneration.test.ts(114 tests)test-t3-appmodel-picker verificationNote
Discover Claude models from SDK initialization instead of static fallback
init.modelsreturned by the SDK, building a live model catalog with effort,fastMode, and thinking options derived from SDK-provided flags.FALLBACK_CLAUDE_MODELSstatic list.fastMode/thinking directly from model selection options rather than requiring catalog descriptors.[1m](e.g.opus[1m]) are assigned a 1,000,000-token context window, andxhigheffort is preserved for newer models instead of being mapped tomax.📊 Macroscope summarized fc3bf5d. 4 files reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted
🗂️ Filtered Issues
No issues evaluated.
Note
Medium Risk
Changes core provider inventory, merge behavior, and how model options are passed into Claude sessions and text generation; mistakes could show wrong models or mis-forward effort/settings, but behavior is heavily covered by new tests.
Overview
Claude model inventory now comes from the Agent SDK initialization handshake when the probe returns models, instead of relying primarily on a version-gated static catalog. The static list remains a fallback when discovery is empty or the init probe fails.
Discovery maps each SDK
ModelInfointo picker entries with effort, fast mode, and thinking options derived from the advertised flags (including ultrathink on effort selects). Provider status prefers discovered models and skips version-upgrade nags when any are present. ProviderRegistry treats Claude like OpenCode for merge semantics so successful refreshes replace stale fallback slugs and warning snapshots with the full fallback catalog do not union with old discovered IDs.Sessions and CLI text generation forward effort, fast mode, thinking, and ultrathink correctly for SDK-only model IDs (e.g.
opus[1m]) by reading selections directly when there is no static capability catalog. Context window handling treats[1m]suffixes as 1M tokens.xhigh→maxCLI normalization is narrowed to a specific set of older catalog models.Reviewed by Cursor Bugbot for commit cd20057. Bugbot is set up for automated code reviews on this repo. Configure here.