Skip to content
Source
Sign inSign up
TanStack/ai

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

Mergedtombeckenhammerged 1 commit intomain from880-claude-sonnet-5-and-fable-supportmerged by AlemTuzlak View on GitHub

tombeckenhamcommented

🎯 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 (#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.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      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 3fbdd672d6fd67278575f6fd2a5d58b998d500c0 and e548186e8006e1dc52cf3b4abaa28fa343cc783d.

      📒 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 nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the main change: first-class support for Claude Sonnet 5 and Claude Fable 5.
      Description check✅ PassedThe description matches the template with Changes, Checklist, and Release Impact sections and gives a substantive summary of the work.
      Linked Issues check✅ PassedThe PR implements the requested Sonnet 5 and Fable support from #880, including typing, capabilities, metadata, docs, and tests.
      Out of Scope Changes check✅ PassedThe added docs, tests, and model metadata stay aligned with the new Sonnet 5/Fable support and its capability wiring.
      Docstring Coverage✅ PassedNo 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.
    2. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Changeset Version Preview

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

      🟨 Minor bumps

      PackageVersionReason
      @tanstack/ai-anthropic0.15.13 → 0.16.0Changeset

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/ai0.39.0 → 0.39.1Changeset
      @tanstack/ai-ollama0.8.12 → 0.8.13Changeset
      @tanstack/ai-angular0.2.1 → 0.2.2Dependent
      @tanstack/ai-bedrock0.1.0 → 0.1.1Dependent
      @tanstack/ai-client0.19.1 → 0.19.2Dependent
      @tanstack/ai-code-mode0.3.4 → 0.3.5Dependent
      @tanstack/ai-code-mode-skills0.3.7 → 0.3.8Dependent
      @tanstack/ai-devtools-core0.4.20 → 0.4.21Dependent
      @tanstack/ai-fal0.9.8 → 0.9.9Dependent
      @tanstack/ai-isolate-cloudflare0.2.34 → 0.2.35Dependent
      @tanstack/ai-isolate-node0.1.43 → 0.1.44Dependent
      @tanstack/ai-isolate-quickjs0.1.43 → 0.1.44Dependent
      @tanstack/ai-mcp0.2.1 → 0.2.2Dependent
      @tanstack/ai-preact0.10.1 → 0.10.2Dependent
      @tanstack/ai-react0.16.2 → 0.16.3Dependent
      @tanstack/ai-solid0.14.1 → 0.14.2Dependent
      @tanstack/ai-svelte0.14.1 → 0.14.2Dependent
      @tanstack/ai-vue0.14.1 → 0.14.2Dependent
      @tanstack/ai-vue-ui0.2.29 → 0.2.30Dependent
      @tanstack/preact-ai-devtools0.1.63 → 0.1.64Dependent
      @tanstack/react-ai-devtools0.2.63 → 0.2.64Dependent
      @tanstack/solid-ai-devtools0.2.63 → 0.2.64Dependent
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 3fbdd672d6fd67278575f6fd2a5d58b998d500c0

      CommandStatusDurationResult
      nx run-many --targets=build --exclude=examples/...✅ Succeeded2sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-07-02 09:58:00 UTC

    4. 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

    5. 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 e14586b3e2bc32f7640b79df51c7ca9ac6f87295 and 3fbdd672d6fd67278575f6fd2a5d58b998d500c0.

      📒 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
    6. AlemTuzlak approved these changes

    7. AlemTuzlak merged this091e820

    8. AlemTuzlak closed this

Sign in to join this conversation.