feat(ai-anthropic): first-class Claude Sonnet 5 and Claude Fable 5 support #884
main from880-claude-sonnet-5-and-fable-support·merged by AlemTuzlak View on GitHub🎯 Changes#
Closes #880.
The claude-sonnet-5 and claude-fable-5 entries landed mechanically via the OpenRouter metadata sync (#772), but the models were never wired into the adapter's capability maps — they were selectable without per-model type safety, provider-tool typing, or the native combined tools+schema path. This PR adds proper support:
- Per-model provider options now match the API surface, enforced at compile time:
claude-fable-5: thinking is always on — only{ type: 'adaptive' }is accepted (disabledandbudget_tokensboth 400 on the API and are now type errors).claude-sonnet-5: adaptive thinking by default with an explicitdisabledopt-out;budget_tokensrejected.- Neither model accepts
temperature/top_p/top_k(the API rejects them);max_tokensis kept via a newAnthropicMaxTokensOptions.
output_config.effortgains the'xhigh'level (Opus 4.7+, Sonnet 5, Fable 5).- Native combined tools + output-schema (#605 path): both models registered in
ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS, plus the missingclaude-opus-4.8/claude-opus-4.8-fastentries. - Tool-capability type map now covers
claude-sonnet-5,claude-fable-5,claude-opus-4-7-fast,claude-opus-4.8, andclaude-opus-4.8-fast— previously these resolved to an empty capability list, so provider tools (web search, bash, etc.) failed to type-check on them. - Model metadata:
adaptive_thinkingflags on both entries; Sonnet 5 pricing corrected to the sticker $3/$15 per MTok (the synced values were the introductory $2/$10 that expires 2026-08-31). - Tests: per-model type-safety coverage (modelOptions gating + tool superset) for both models, and runtime assertions that
supportsCombinedToolsAndSchema()is true for them. - Docs + skill:
docs/adapters/anthropic.mdgains an Adaptive Thinking section covering the per-model rules (kiira-checked snippet), and theadapter-configurationskill reference is updated in the same PR.
E2E note: the aimock-based e2e suite pins a fixed recorded model per provider, so model-metadata additions have no e2e-observable surface; coverage follows the repo's established pattern of compile-time per-model tests plus adapter unit tests. Full e2e suite run locally to confirm no regressions (339 passed, 1 skipped).
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested this code locally with
pnpm run test:pr.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
🤖 Generated with Claude Code
Summary by CodeRabbit#
- New Features
- Added first-class support for Claude Sonnet 5 and Claude Fable 5, including improved tool and output-schema handling.
- Extended
output_config.effortwith a newxhighlevel for supported models.
- Documentation
- Updated Anthropic adapter references and examples for the latest Claude model options, including adaptive thinking and
xhigheffort behavior.
- Updated Anthropic adapter references and examples for the latest Claude model options, including adaptive thinking and
- Bug Fixes
- Enforced stricter, model-specific validation for “thinking” and disallowed unsupported sampling-related settings.
- Tests
- Added type-safety and behavior coverage for the new models’ options and tool support.
- 1
🚀 Changeset Version Preview#
3 package(s) bumped directly, 20 bumped as dependents.
🟨 Minor bumps#
Package Version Reason @tanstack/ai-anthropic0.15.13 → 0.16.0 Changeset 🟩 Patch bumps#
Package Version Reason @tanstack/ai0.39.0 → 0.39.1 Changeset @tanstack/ai-ollama0.8.12 → 0.8.13 Changeset @tanstack/ai-angular0.2.1 → 0.2.2 Dependent @tanstack/ai-bedrock0.1.0 → 0.1.1 Dependent @tanstack/ai-client0.19.1 → 0.19.2 Dependent @tanstack/ai-code-mode0.3.4 → 0.3.5 Dependent @tanstack/ai-code-mode-skills0.3.7 → 0.3.8 Dependent @tanstack/ai-devtools-core0.4.20 → 0.4.21 Dependent @tanstack/ai-fal0.9.8 → 0.9.9 Dependent @tanstack/ai-isolate-cloudflare0.2.34 → 0.2.35 Dependent @tanstack/ai-isolate-node0.1.43 → 0.1.44 Dependent @tanstack/ai-isolate-quickjs0.1.43 → 0.1.44 Dependent @tanstack/ai-mcp0.2.1 → 0.2.2 Dependent @tanstack/ai-preact0.10.1 → 0.10.2 Dependent @tanstack/ai-react0.16.2 → 0.16.3 Dependent @tanstack/ai-solid0.14.1 → 0.14.2 Dependent @tanstack/ai-svelte0.14.1 → 0.14.2 Dependent @tanstack/ai-vue0.14.1 → 0.14.2 Dependent @tanstack/ai-vue-ui0.2.29 → 0.2.30 Dependent @tanstack/preact-ai-devtools0.1.63 → 0.1.64 Dependent @tanstack/react-ai-devtools0.2.63 → 0.2.64 Dependent @tanstack/solid-ai-devtools0.2.63 → 0.2.64 Dependent View your CI Pipeline Execution ↗ for commit 3fbdd672d6fd67278575f6fd2a5d58b998d500c0
Command Status Duration Result nx run-many --targets=build --exclude=examples/...✅ Succeeded 2s View ↗
☁️ Nx Cloud last updated this comment at
2026-07-02 09:58:00UTC@tanstack/ai
npm i https://pkg.pr.new/@tanstack/ai@884@tanstack/ai-acp
npm i https://pkg.pr.new/@tanstack/ai-acp@884@tanstack/ai-angular
npm i https://pkg.pr.new/@tanstack/ai-angular@884@tanstack/ai-anthropic
npm i https://pkg.pr.new/@tanstack/ai-anthropic@884@tanstack/ai-bedrock
npm i https://pkg.pr.new/@tanstack/ai-bedrock@884@tanstack/ai-claude-code
npm i https://pkg.pr.new/@tanstack/ai-claude-code@884@tanstack/ai-client
npm i https://pkg.pr.new/@tanstack/ai-client@884@tanstack/ai-code-mode
npm i https://pkg.pr.new/@tanstack/ai-code-mode@884@tanstack/ai-code-mode-skills
npm i https://pkg.pr.new/@tanstack/ai-code-mode-skills@884@tanstack/ai-codex
npm i https://pkg.pr.new/@tanstack/ai-codex@884@tanstack/ai-devtools-core
npm i https://pkg.pr.new/@tanstack/ai-devtools-core@884@tanstack/ai-elevenlabs
npm i https://pkg.pr.new/@tanstack/ai-elevenlabs@884@tanstack/ai-event-client
npm i https://pkg.pr.new/@tanstack/ai-event-client@884@tanstack/ai-fal
npm i https://pkg.pr.new/@tanstack/ai-fal@884@tanstack/ai-gemini
npm i https://pkg.pr.new/@tanstack/ai-gemini@884@tanstack/ai-grok
npm i https://pkg.pr.new/@tanstack/ai-grok@884@tanstack/ai-grok-build
npm i https://pkg.pr.new/@tanstack/ai-grok-build@884@tanstack/ai-groq
npm i https://pkg.pr.new/@tanstack/ai-groq@884@tanstack/ai-isolate-cloudflare
npm i https://pkg.pr.new/@tanstack/ai-isolate-cloudflare@884@tanstack/ai-isolate-node
npm i https://pkg.pr.new/@tanstack/ai-isolate-node@884@tanstack/ai-isolate-quickjs
npm i https://pkg.pr.new/@tanstack/ai-isolate-quickjs@884@tanstack/ai-mcp
npm i https://pkg.pr.new/@tanstack/ai-mcp@884@tanstack/ai-mistral
npm i https://pkg.pr.new/@tanstack/ai-mistral@884@tanstack/ai-ollama
npm i https://pkg.pr.new/@tanstack/ai-ollama@884@tanstack/ai-openai
npm i https://pkg.pr.new/@tanstack/ai-openai@884@tanstack/ai-opencode
npm i https://pkg.pr.new/@tanstack/ai-opencode@884@tanstack/ai-openrouter
npm i https://pkg.pr.new/@tanstack/ai-openrouter@884@tanstack/ai-preact
npm i https://pkg.pr.new/@tanstack/ai-preact@884@tanstack/ai-react
npm i https://pkg.pr.new/@tanstack/ai-react@884@tanstack/ai-react-ui
npm i https://pkg.pr.new/@tanstack/ai-react-ui@884@tanstack/ai-sandbox
npm i https://pkg.pr.new/@tanstack/ai-sandbox@884@tanstack/ai-sandbox-cloudflare
npm i https://pkg.pr.new/@tanstack/ai-sandbox-cloudflare@884@tanstack/ai-sandbox-daytona
npm i https://pkg.pr.new/@tanstack/ai-sandbox-daytona@884@tanstack/ai-sandbox-docker
npm i https://pkg.pr.new/@tanstack/ai-sandbox-docker@884@tanstack/ai-sandbox-local-process
npm i https://pkg.pr.new/@tanstack/ai-sandbox-local-process@884@tanstack/ai-sandbox-sprites
npm i https://pkg.pr.new/@tanstack/ai-sandbox-sprites@884@tanstack/ai-sandbox-vercel
npm i https://pkg.pr.new/@tanstack/ai-sandbox-vercel@884@tanstack/ai-solid
npm i https://pkg.pr.new/@tanstack/ai-solid@884@tanstack/ai-solid-ui
npm i https://pkg.pr.new/@tanstack/ai-solid-ui@884@tanstack/ai-svelte
npm i https://pkg.pr.new/@tanstack/ai-svelte@884@tanstack/ai-utils
npm i https://pkg.pr.new/@tanstack/ai-utils@884@tanstack/ai-vue
npm i https://pkg.pr.new/@tanstack/ai-vue@884@tanstack/ai-vue-ui
npm i https://pkg.pr.new/@tanstack/ai-vue-ui@884@tanstack/openai-base
npm i https://pkg.pr.new/@tanstack/openai-base@884@tanstack/preact-ai-devtools
npm i https://pkg.pr.new/@tanstack/preact-ai-devtools@884@tanstack/react-ai-devtools
npm i https://pkg.pr.new/@tanstack/react-ai-devtools@884@tanstack/solid-ai-devtools
npm i https://pkg.pr.new/@tanstack/solid-ai-devtools@884commit:
e548186Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/ai-anthropic/src/model-meta.ts (1)
769-808: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winSet
priority_tiertofalsefor Claude Sonnet 5. Anthropic lists Sonnet 5 as not supporting Priority Tier, so leaving thistrueadvertises a capability the API rejects.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai-anthropic/src/model-meta.ts` around lines 769 - 808, The CLAUDE_SONNET_5 metadata incorrectly advertises Priority Tier support via supports.priority_tier. Update the CLAUDE_SONNET_5 entry in model-meta.ts to set this capability to false so the ModelMeta definition matches Anthropic’s actual API support and doesn’t expose an unsupported option.🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@packages/ai-anthropic/src/text/text-provider-options.ts`: - Around line 245-249: The `effort` doc note is too broad for the current public typings in `AnthropicChatModelProviderOptionsByName`, since the Claude Opus 4.7/4.7 Fast/4.8/4.8 Fast entries still use `AnthropicThinkingOptions & AnthropicSamplingOptions` and do not expose `output_config.effort`. Update the model-specific option mapping so those entries also include `AnthropicOutputConfigOptions` and `AnthropicMaxTokensOptions`, or narrow the `xhigh` comment in `text-provider-options.ts` to only the models whose type actually exposes `output_config.effort`. --- Outside diff comments: In `@packages/ai-anthropic/src/model-meta.ts`: - Around line 769-808: The CLAUDE_SONNET_5 metadata incorrectly advertises Priority Tier support via supports.priority_tier. Update the CLAUDE_SONNET_5 entry in model-meta.ts to set this capability to false so the ModelMeta definition matches Anthropic’s actual API support and doesn’t expose an unsupported option.🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
7caa1b00-50ff-4927-9d40-b4cf3c31a9f2📥 Commits
Reviewing files that changed from the base of the PR and between e14586b3e2bc32f7640b79df51c7ca9ac6f87295 and 3fbdd672d6fd67278575f6fd2a5d58b998d500c0.
📒 Files selected for processing (9)
.changeset/anthropic-sonnet-5-fable-5-support.mddocs/adapters/anthropic.mddocs/config.jsonpackages/ai-anthropic/src/model-meta.tspackages/ai-anthropic/src/text/text-provider-options.tspackages/ai-anthropic/tests/anthropic-adapter.test.tspackages/ai-anthropic/tests/chat-per-model-type-safety.test.tspackages/ai-anthropic/tests/tools-per-model-type-safety.test.tspackages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md
packages/ai-anthropic/src/text/text-provider-options.ts lines 245 to 249OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -182,4 +242,8 @@182242 * preserved when the engine adds `format`.183243 */184244 output_config?: {185- effort?: 'low' | 'medium' | 'high' | 'max' | null245+ /**246+ * `'xhigh'` is accepted on Claude Opus 4.7+, Claude Sonnet 5, and247+ * Claude Fable 5; older models support `'low'`–`'max'` only.248+ */249+ effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max' | null🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🌐 Web query:
Does Claude Opus 4.7 reject temperature top_p top_k with a 400 error and only support adaptive thinking?💡 Result:
Yes, that is correct. For Claude Opus 4.7, sending temperature, top_p, or top_k parameters in your API request will result in a 400 error [1][2][3]. Anthropic's migration documentation explicitly instructs users to remove these parameters entirely from the request payload [1][4]. Additionally, Claude Opus 4.7 does not support manual extended thinking configurations such as
thinking: {type: "enabled", budget_tokens: N}. Using this format will also trigger a 400 error [4][5][6]. The model instead supports "adaptive thinking," which is enabled by settingthinking: {type: "adaptive"}[4][5]. When adaptive thinking is enabled, you can control the reasoning depth using theoutput_config.effortparameter [2][4]. If you do not include athinkingfield in your request, the model operates without thinking by default [4][7].Citations:
- 1: https://platform.claude.com/docs/en/about-claude/models/migration-guide
- 2: https://clauder-navi.com/en/claude-opus-4-7-migration-guide/
- 3: https://zenn.dev/knowledge_graph/articles/claude-opus-47-breaking-changes?locale=en
- 4: https://platform.claude.com/docs/en/about-claude/models/migration-guide?fcdaa149_sort_date=desc&vid=39
- 5: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking?fcdaa149_sort_date=desc
- 6: https://platform.claude.com/docs/en/about-claude/models/migration-guide?8adb0641_page=2
- 7: https://platform.claude.com/docs/en/about-claude/models/whats-new-claude-4-8
🏁 Script executed:
ast-grep outline packages/ai-anthropic/src/model-meta.ts --view expandedRepository: TanStack/ai
Length of output: 1278
🏁 Script executed:
ast-grep outline packages/ai-anthropic/src/text/text-provider-options.ts --view expandedRepository: TanStack/ai
Length of output: 2446
🏁 Script executed:
sed -n '520,820p' packages/ai-anthropic/src/model-meta.tsRepository: TanStack/ai
Length of output: 7036
🏁 Script executed:
sed -n '220,320p' packages/ai-anthropic/src/text/text-provider-options.tsRepository: TanStack/ai
Length of output: 3935
🏁 Script executed:
sed -n '330,390p' packages/ai-anthropic/src/text/text-provider-options.tsRepository: TanStack/ai
Length of output: 2013
🏁 Script executed:
sed -n '860,980p' packages/ai-anthropic/src/model-meta.tsRepository: TanStack/ai
Length of output: 4553
🏁 Script executed:
rg -n "AnthropicChatModelProviderOptionsByName|output_config|effort" packages/ai-anthropic/src/model-meta.ts packages/ai-anthropic/src/text/text-provider-options.tsRepository: TanStack/ai
Length of output: 1940
Scope the
xhighnote to the models that actually exposeoutput_config.effort.AnthropicChatModelProviderOptionsByNamestill mapsCLAUDE_OPUS_4_7/4_7_FAST/4_8/4_8_FASTto the legacyAnthropicThinkingOptions & AnthropicSamplingOptionsshape, so callers for those models still can’t passoutput_config.effortthrough the public type. Either narrow the comment or extend those model entries to includeAnthropicOutputConfigOptions/AnthropicMaxTokensOptions.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai-anthropic/src/text/text-provider-options.ts` around lines 245 - 249, The `effort` doc note is too broad for the current public typings in `AnthropicChatModelProviderOptionsByName`, since the Claude Opus 4.7/4.7 Fast/4.8/4.8 Fast entries still use `AnthropicThinkingOptions & AnthropicSamplingOptions` and do not expose `output_config.effort`. Update the model-specific option mapping so those entries also include `AnthropicOutputConfigOptions` and `AnthropicMaxTokensOptions`, or narrow the `xhigh` comment in `text-provider-options.ts` to only the models whose type actually exposes `output_config.effort`.✅ Addressed in commits 86fbbdd to e548186
AlemTuzlak approved these changes
AlemTuzlak merged this091e820
AlemTuzlak closed this
Sign in to join this conversation.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
1f374efb-b114-4a86-b44c-343fb33b8741📥 Commits
Reviewing files that changed from the base of the PR and between 3fbdd672d6fd67278575f6fd2a5d58b998d500c0 and e548186e8006e1dc52cf3b4abaa28fa343cc783d.
📒 Files selected for processing (9)
.changeset/anthropic-sonnet-5-fable-5-support.mddocs/adapters/anthropic.mddocs/config.jsonpackages/ai-anthropic/src/model-meta.tspackages/ai-anthropic/src/text/text-provider-options.tspackages/ai-anthropic/tests/anthropic-adapter.test.tspackages/ai-anthropic/tests/chat-per-model-type-safety.test.tspackages/ai-anthropic/tests/tools-per-model-type-safety.test.tspackages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md✅ Files skipped from review due to trivial changes (2)
🚧 Files skipped from review as they are similar to previous changes (7)
📝 Walkthrough
Walkthrough#
This PR adds Claude Sonnet 5 and Claude Fable 5 support to the Anthropic adapter. It updates model metadata, provider option typing, combined tools+schema capability registration, tests, and docs, and adds the
output_config.effort'xhigh'level.Changes#
Sonnet 5 / Fable 5 support
packages/ai-anthropic/src/text/text-provider-options.tsoutput_config.effortto include'xhigh'.packages/ai-anthropic/src/model-meta.tspackages/ai-anthropic/tests/chat-per-model-type-safety.test.ts,packages/ai-anthropic/tests/tools-per-model-type-safety.test.ts,packages/ai-anthropic/tests/anthropic-adapter.test.ts.changeset/anthropic-sonnet-5-fable-5-support.md,docs/adapters/anthropic.md,docs/config.json,packages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.mdEstimated code review effort: 3 (Moderate) | ~25 minutes
Possibly related PRs
Suggested reviewers:
AlemTuzlak🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
#880, including typing, capabilities, metadata, docs, and tests.✨ Finishing Touches
📝 Generate docstrings
🧪 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.
❤️ Share