Skip to content

feat(ai-anthropic): first-class Claude Sonnet 5 and Claude Fable 5 support#884

Merged
AlemTuzlak merged 1 commit into
mainfrom
880-claude-sonnet-5-and-fable-support
Jul 2, 2026
Merged

feat(ai-anthropic): first-class Claude Sonnet 5 and Claude Fable 5 support#884
AlemTuzlak merged 1 commit into
mainfrom
880-claude-sonnet-5-and-fable-support

Conversation

@tombeckenham

@tombeckenham tombeckenham commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🎯 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 (disabled and budget_tokens both 400 on the API and are now type errors).
    • claude-sonnet-5: adaptive thinking by default with an explicit disabled opt-out; budget_tokens rejected.
    • Neither model accepts temperature / top_p / top_k (the API rejects them); max_tokens is kept via a new AnthropicMaxTokensOptions.
  • output_config.effort gains the 'xhigh' level (Opus 4.7+, Sonnet 5, Fable 5).
  • Native combined tools + output-schema (Route structured-output through native combined-mode where supported (skip finalization round-trip) #605 path): both models registered in ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS, plus the missing claude-opus-4.8 / claude-opus-4.8-fast entries.
  • Tool-capability type map now covers claude-sonnet-5, claude-fable-5, claude-opus-4-7-fast, claude-opus-4.8, and claude-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_thinking flags 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.md gains an Adaptive Thinking section covering the per-model rules (kiira-checked snippet), and the adapter-configuration skill 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.effort with a new xhigh level for supported models.
  • Documentation
    • Updated Anthropic adapter references and examples for the latest Claude model options, including adaptive thinking and xhigh effort behavior.
  • 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.

@tombeckenham tombeckenham linked an issue Jul 2, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

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 3fbdd67 and e548186.

📒 Files selected for processing (9)
  • .changeset/anthropic-sonnet-5-fable-5-support.md
  • docs/adapters/anthropic.md
  • docs/config.json
  • packages/ai-anthropic/src/model-meta.ts
  • packages/ai-anthropic/src/text/text-provider-options.ts
  • packages/ai-anthropic/tests/anthropic-adapter.test.ts
  • packages/ai-anthropic/tests/chat-per-model-type-safety.test.ts
  • packages/ai-anthropic/tests/tools-per-model-type-safety.test.ts
  • packages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md
✅ Files skipped from review due to trivial changes (2)
  • docs/config.json
  • .changeset/anthropic-sonnet-5-fable-5-support.md
🚧 Files skipped from review as they are similar to previous changes (7)
  • packages/ai-anthropic/tests/tools-per-model-type-safety.test.ts
  • packages/ai-anthropic/tests/anthropic-adapter.test.ts
  • packages/ai-anthropic/src/text/text-provider-options.ts
  • packages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md
  • packages/ai-anthropic/tests/chat-per-model-type-safety.test.ts
  • docs/adapters/anthropic.md
  • packages/ai-anthropic/src/model-meta.ts

📝 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

Layer / File(s) Summary
Provider option types for adaptive thinking and xhigh effort
packages/ai-anthropic/src/text/text-provider-options.ts
Adds adaptive-thinking and max-tokens option interfaces, and extends output_config.effort to include 'xhigh'.
Model metadata and type maps
packages/ai-anthropic/src/model-meta.ts
Updates Claude Fable 5 and Sonnet 5 metadata, pricing, combined tools+schema registration, and provider/tool capability type maps for the new option shapes.
Tests for new model gating and capabilities
packages/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
Adds compile-time option/tool gating tests and a runtime assertion that both models support combined tools and schema.
Documentation and changeset updates
.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.md
Adds the changeset, updates Anthropic adapter docs and reference tables, and refreshes the docs navigation timestamp.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • TanStack/ai#609: Extends the same combined-tools-and-schema model allowlist and related Anthropic typing surface for the new model IDs.

Suggested reviewers: AlemTuzlak

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: first-class support for Claude Sonnet 5 and Claude Fable 5.
Description check ✅ Passed The description matches the template with Changes, Checklist, and Release Impact sections and gives a substantive summary of the work.
Linked Issues check ✅ Passed The PR implements the requested Sonnet 5 and Fable support from #880, including typing, capabilities, metadata, docs, and tests.
Out of Scope Changes check ✅ Passed The added docs, tests, and model metadata stay aligned with the new Sonnet 5/Fable support and its capability wiring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 880-claude-sonnet-5-and-fable-support

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

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

3 package(s) bumped directly, 20 bumped as dependents.

🟨 Minor bumps

Package Version Reason
@tanstack/ai-anthropic 0.15.13 → 0.16.0 Changeset

🟩 Patch bumps

Package Version Reason
@tanstack/ai 0.39.0 → 0.39.1 Changeset
@tanstack/ai-ollama 0.8.12 → 0.8.13 Changeset
@tanstack/ai-angular 0.2.1 → 0.2.2 Dependent
@tanstack/ai-bedrock 0.1.0 → 0.1.1 Dependent
@tanstack/ai-client 0.19.1 → 0.19.2 Dependent
@tanstack/ai-code-mode 0.3.4 → 0.3.5 Dependent
@tanstack/ai-code-mode-skills 0.3.7 → 0.3.8 Dependent
@tanstack/ai-devtools-core 0.4.20 → 0.4.21 Dependent
@tanstack/ai-fal 0.9.8 → 0.9.9 Dependent
@tanstack/ai-isolate-cloudflare 0.2.34 → 0.2.35 Dependent
@tanstack/ai-isolate-node 0.1.43 → 0.1.44 Dependent
@tanstack/ai-isolate-quickjs 0.1.43 → 0.1.44 Dependent
@tanstack/ai-mcp 0.2.1 → 0.2.2 Dependent
@tanstack/ai-preact 0.10.1 → 0.10.2 Dependent
@tanstack/ai-react 0.16.2 → 0.16.3 Dependent
@tanstack/ai-solid 0.14.1 → 0.14.2 Dependent
@tanstack/ai-svelte 0.14.1 → 0.14.2 Dependent
@tanstack/ai-vue 0.14.1 → 0.14.2 Dependent
@tanstack/ai-vue-ui 0.2.29 → 0.2.30 Dependent
@tanstack/preact-ai-devtools 0.1.63 → 0.1.64 Dependent
@tanstack/react-ai-devtools 0.2.63 → 0.2.64 Dependent
@tanstack/solid-ai-devtools 0.2.63 → 0.2.64 Dependent

@nx-cloud

nx-cloud Bot commented Jul 2, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3fbdd67

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:00 UTC

…pport

The claude-sonnet-5 and claude-fable-5 entries landed mechanically via the
OpenRouter metadata sync (#772) but were never wired into the adapter's
capability maps, so the models were selectable without per-model type
safety or the native combined tools+schema path.

- Per-model provider options now match the API surface: Fable 5 accepts
  only adaptive thinking (explicit disabled/budget_tokens 400), Sonnet 5
  accepts adaptive or disabled, and neither accepts temperature/top_p/top_k
- output_config.effort gains the 'xhigh' level (Opus 4.7+, Sonnet 5, Fable 5)
- Both models registered in ANTHROPIC_COMBINED_TOOLS_AND_SCHEMA_MODELS
  (plus the missing claude-opus-4.8 / 4.8-fast entries)
- Tool-capability type map covers sonnet-5, fable-5, opus-4-7-fast,
  opus-4.8, opus-4.8-fast so provider tools type-check on those models
- Model metadata: adaptive_thinking flags; Sonnet 5 sticker pricing ($3/$15)
- Docs, adapter-configuration skill reference, and changeset updated

Closes #880

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@tombeckenham tombeckenham force-pushed the 880-claude-sonnet-5-and-fable-support branch from 3fbdd67 to e548186 Compare July 2, 2026 09:56
@pkg-pr-new

pkg-pr-new Bot commented Jul 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@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@884

commit: e548186

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable 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 win

Set priority_tier to false for Claude Sonnet 5. Anthropic lists Sonnet 5 as not supporting Priority Tier, so leaving this true advertises 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 e14586b and 3fbdd67.

📒 Files selected for processing (9)
  • .changeset/anthropic-sonnet-5-fable-5-support.md
  • docs/adapters/anthropic.md
  • docs/config.json
  • packages/ai-anthropic/src/model-meta.ts
  • packages/ai-anthropic/src/text/text-provider-options.ts
  • packages/ai-anthropic/tests/anthropic-adapter.test.ts
  • packages/ai-anthropic/tests/chat-per-model-type-safety.test.ts
  • packages/ai-anthropic/tests/tools-per-model-type-safety.test.ts
  • packages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md

Comment thread packages/ai-anthropic/src/text/text-provider-options.ts
@AlemTuzlak AlemTuzlak merged commit 091e820 into main Jul 2, 2026
10 checks passed
@AlemTuzlak AlemTuzlak deleted the 880-claude-sonnet-5-and-fable-support branch July 2, 2026 10:22
@github-actions github-actions Bot mentioned this pull request Jul 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Claude Sonnet 5 and Fable support

2 participants