fix(ai-anthropic): match claude-sonnet-5-5 options and tools to the Claude API #1594
main fromrefs/pull/1594/head·merged by tombeckenham View on GitHubOn claude-sonnet-5-5, the types accept temperature, top_p, top_k, and computerUseTool(). The Claude API returns a 400 for computerUseTool() and for any non-default sampling value. The types also reject output_config, so setting effort, the main control for this model, needs a cast. The model sync added the id in #1516 without the hand edits that newer Claude models need. This PR sets the model's options and tools by hand, the same way claude-opus-5-5 and claude-fable-5-1 are set.
🎯 Changes#
model-meta.ts:claude-sonnet-5-5takesAnthropicMaxTokensOptionsandAnthropicOutputConfigOptionsin place ofAnthropicSamplingOptions, in both thesatisfies ModelMetaclause andAnthropicChatModelProviderOptionsByName.computer_useleaves its tool list, with the same comment asclaude-opus-5-5. The other six provider tools stay.model-meta.tscomments: one above the constant and one in the options map, like the hand-setclaude-fable-5andclaude-sonnet-5entries.- Tests: a
claude-sonnet-5-5block inchat-per-model-type-safety.test.tsand two cases intools-per-model-type-safety.test.ts, written like theclaude-fable-5andclaude-opus-5-5cases. A new E2E route and spec (anthropic-sonnet-5-5-wire) sendoutput_config.effortthrough the adapter and check the request. - Docs and skill reference: Sonnet 5.5 joins the per-model rules,
effort, andoutput_configlists indocs/adapters/anthropic.mdand in theadapter-configurationAnthropic reference. The computer use lines indocs/adapters/anthropic.mdanddocs/tools/provider-tools.mdnow name the models that do not takecomputerUseTool(). - Follow-up doc fixes from review: the skill reference now lists
claude-fable-5-1andclaude-opus-5-5as models that rejectthinking: { type: 'disabled' }, andclaude-fable-5-1as a model that rejects sampling values.docs/adapters/anthropic.mdsays thatclaude-opus-5-fasttakes no provider tools. Theoutput_config.effortJSDoc names Sonnet 5.5 forxhigh.docs/config.jsonhas a newupdatedAtfor the Anthropic adapter page. - The branch has a merge of
main(7fb4a5f7f). The only conflict was the generatedrouteTree.gen.ts. - Changeset: patch for
@tanstack/ai-anthropic.
Sources: the Sonnet 5.5 overview ("Setting temperature, top_p, or top_k to a non-default value returns a 400 error"), and What's new in Claude Sonnet 5.5 ("supports computer use only through the computer_toolset_20260801 toolset", and "the effort parameter controls thinking depth"). For the docs line on Opus 5.5: What's new in Claude Opus 5.5 ("Claude Opus 5.5 supports only the toolset").
✅ Checklist#
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I fully understand the code in this pull request, including any code generated with AI assistance.
- Docs: I updated
docs/for this change, or this change is not user-facing. - Changeset: I added a changeset (
pnpm changeset), or this PR does not change a published package.
🚀 Release Impact#
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Root cause#
Issue. On claude-sonnet-5-5, the adapter types accept temperature, top_p, top_k, and computerUseTool(). The Claude API returns a 400 for computerUseTool() and for any non-default sampling value. computerUseTool() sends computer_20241022 or computer_20250124, and this model takes computer use only through the computer_toolset_20260801 toolset. The types reject output_config, so a caller cannot set effort without a cast.
Cause. buildAnthropicProviderOptionsType in scripts/model-sync/provider-supports.ts picks the option mix from the OpenRouter catalog. The catalog lists temperature for anthropic/claude-sonnet-5.5 and marks reasoning as mandatory. So the function chose adaptive-only thinking plus AnthropicSamplingOptions, and it adds AnthropicOutputConfigOptions only when there is no sampling. That skips the rule in CONTRIBUTING: "reasoning.mandatory → AnthropicAdaptiveOnlyThinkingOptions plus AnthropicOutputConfigOptions". The tool list is the generic ANTHROPIC_SERVER_TOOLS, which includes computer_use, while CONTRIBUTING says not to copy a tool list.
Fix. Give claude-sonnet-5-5 the option mix that claude-fable-5-1 has, with its adaptive-only thinking unchanged, and drop computer_use as claude-opus-5-5 does. The sync only inserts ids that are not in the file yet, so the hand edit survives later syncs.
Possible alternatives#
- Fix the generator. Add
AnthropicOutputConfigOptionswhenever reasoning is mandatory, as CONTRIBUTING says, and stop writingcomputer_usefor new models. That covers future models too, but the catalog still liststemperaturehere, so this id needs the hand edit anyway. It is a separate change to the generator. - Keep the sampling options and only add
output_config. Smaller, buttemperaturewould still compile and fail at runtime.
Testing#
Commands run
On
main(3a09cf044), the new type tests failtscwith 8 errors:output_configis rejected twice (the call and thetoHavePropertycheck), two@ts-expect-errorlines fortemperatureandtop_kare unused, the threenot.toHavePropertychecks for sampling fail, and thecomputerUseTool()@ts-expect-erroris unused. On this branch,tscpasses. Thedisabledandbudget_tokenscases pass on both:mainalready types this model's thinking as adaptive-only, and the cases keep it that way.On
main, the new E2E route failstsc:'output_config' does not exist in type ... AnthropicSamplingOptions. On this branch,tscfortesting/e2epasses, andplaywright test tests/anthropic-sonnet-5-5-wire.spec.ts tests/anthropic-opus-5-combined-wire.spec.ts: 7 passed. I did not run the full E2E suite: this change is types only, and nothing else in the repo usesclaude-sonnet-5-5.I reverted each hunk of
model-meta.tsin turn. Each one makestscfail.@tanstack/ai-anthropic: unit tests175 passed,test:oxlintclean,tscclean.@tanstack/ai-code-mode-snippets(the only package that depends on it):tscclean.test:docsandtest:kiirapass. I did not runpnpm test:pritself: on my machine its Nx build step starts the Playwright browser download, which hangs.Maintainer repro, after the merge of
main. A new file with three cases ran throughtsc --noEmit -p packages/ai-anthropicin two detached worktrees. The cases:output_config: { effort: 'medium' }compiles,temperaturehas a@ts-expect-error, andcomputerUseTool()has a@ts-expect-error.On
main(7fb4a5f7f), exit 1:tests/zz-repro.ts(11,19): error TS2353: Object literal may only specify known properties, and 'output_config' does not exist in type '... & AnthropicSamplingOptions'. tests/zz-repro.ts(19,5): error TS2578: Unused '@ts-expect-error' directive. tests/zz-repro.ts(29,5): error TS2578: Unused '@ts-expect-error' directive.On this branch (
2034e2cea), exit 0 with no output.After the follow-up doc fixes:
tscfor@tanstack/ai-anthropicpasses andoxfmt --checkpasses on the changed files. The full suite did not run locally. CI is the check for it.
Manual test
- On
main, addmodelOptions: { output_config: { effort: 'medium' } }to achat()call withanthropicText('claude-sonnet-5-5').tscfails:output_configdoes not exist on the options type. - On this branch, run
pnpm --filter @tanstack/ai-anthropic test:types. It passes. - In the
claude-sonnet-5-5block ofchat-per-model-type-safety.test.ts, remove the@ts-expect-errorabovetemperature.tscnow fails, because the model rejects sampling values.
How this PR makes testing easy
- The type tests list what
claude-sonnet-5-5accepts and rejects, next to the cases for the other 5.x models. - The E2E route does not compile if the model loses
output_configagain, and the spec checks thateffortreaches the Messages request.
Risk / rollback#
Low. Types and docs only: the request body does not change. Code that passes temperature, top_p, top_k, or computerUseTool() to claude-sonnet-5-5 now fails to compile. The API already rejected those requests, except sampling values equal to the default, which also stop compiling now. #884 narrowed claude-sonnet-5 the same way. Revert the PR to undo.
Not in this PR:
thinking: { type: "between_tools" }, the API's way to turn off up-front thinking on this model, is not typed yet. The docs say so.tool_choiceany/toolreturn a 400 on this model,claude-opus-5-5, andclaude-fable-5-1. The types still accept them on all three. That is a separate change across three models.
Public API change#
Before
chat({
adapter: anthropicText('claude-sonnet-5-5'),
messages,
modelOptions: { temperature: 0.5 }, // compiles, the API returns a 400
// modelOptions: { output_config: { effort: 'medium' } }, // type error
})
After
chat({
adapter: anthropicText('claude-sonnet-5-5'),
messages,
modelOptions: { output_config: { effort: 'medium' } }, // compiles
// modelOptions: { temperature: 0.5 }, // type error
})
🤖 Generated with Claude Code
Summary by CodeRabbit#
- New Features
- Added Claude Sonnet 5.5 support, including adaptive thinking, effort settings such as
xhigh, and compatible Anthropic provider tools. The model supports up to a 1M-token context and 128K-token output.
- Added Claude Sonnet 5.5 support, including adaptive thinking, effort settings such as
- Documentation
- Clarified that Sonnet 5.5 rejects sampling settings and budget-based thinking, and does not support computer use through the adapter.
- Documented tool support for Opus 5.5 and Sonnet 5.5, and that Opus 5 Fast supports no provider tools.
- 1
github-actions[bot](GitHub profile, opens in a new tab) assignedtombeckenham
Thanks for the PR, @ArVaViT! 🙌 @tombeckenham will take a look.
Automated pre-review checks
- ✅ CI passing
- ✅ No merge conflicts
- ✅ Changeset present
- ✅ E2E test changes included
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
🦋 Changeset detected#
Latest commit: 97c07cf3d59a3005d4cde489eb46bd26b0167541
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Name Type @tanstack/ai-anthropic Patch Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
github-actions[bot](GitHub profile, opens in a new tab) added labelsmerge-conflicts
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: author
github-actions[bot](GitHub profile, opens in a new tab) removed labelswaiting-on: maintainer
tombeckenham approved these changes
View your CI Pipeline Execution ↗ for commit ebfbb930b5b2e8f59d632a9ab3b41f8ce5d7d4ef
Command Status Duration Result nx run-many --targets=build --exclude=examples/...✅ Succeeded 9s View ↗
☁️ Nx Cloud last updated this comment at
2026-10-06 04:44:50UTC@tanstack/ai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@1594@tanstack/ai-acp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-acp@1594@tanstack/ai-angular
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-angular@1594@tanstack/ai-anthropic
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@1594@tanstack/ai-bedrock
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-bedrock@1594@tanstack/ai-byteplus
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-byteplus@1594@tanstack/ai-claude-code
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-claude-code@1594@tanstack/ai-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@1594@tanstack/ai-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cloudflare@1594@tanstack/ai-code-mode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode@1594@tanstack/ai-code-mode-snippets
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-code-mode-snippets@1594@tanstack/ai-codex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-codex@1594@tanstack/ai-cohere
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-cohere@1594@tanstack/ai-compaction
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-compaction@1594@tanstack/ai-devtools-core
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@1594@tanstack/ai-durable-stream
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-durable-stream@1594@tanstack/ai-elevenlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-elevenlabs@1594@tanstack/ai-event-client
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-event-client@1594@tanstack/ai-fal
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-fal@1594@tanstack/ai-gemini
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@1594@tanstack/ai-grok
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok@1594@tanstack/ai-grok-build
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-grok-build@1594@tanstack/ai-groq
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-groq@1594@tanstack/ai-isolate-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-cloudflare@1594@tanstack/ai-isolate-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-daytona@1594@tanstack/ai-isolate-node
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-node@1594@tanstack/ai-isolate-quickjs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs@1594@tanstack/ai-isolate-quickjs-bun
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-isolate-quickjs-bun@1594@tanstack/ai-llmgateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-llmgateway@1594@tanstack/ai-lovable
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-lovable@1594@tanstack/ai-mcp
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mcp@1594@tanstack/ai-memory
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-memory@1594@tanstack/ai-mistral
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-mistral@1594@tanstack/ai-octane
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-octane@1594@tanstack/ai-ollama
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@1594@tanstack/ai-ollaya
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollaya@1594@tanstack/ai-openai
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@1594@tanstack/ai-opencode
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-opencode@1594@tanstack/ai-openrouter
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openrouter@1594@tanstack/ai-perplexity
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-perplexity@1594@tanstack/ai-persistence
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-persistence@1594@tanstack/ai-preact
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-preact@1594@tanstack/ai-react
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@1594@tanstack/ai-react-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@1594@tanstack/ai-reactor
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-reactor@1594@tanstack/ai-remix
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-remix@1594@tanstack/ai-sandbox
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox@1594@tanstack/ai-sandbox-blaxel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-blaxel@1594@tanstack/ai-sandbox-boxd
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-boxd@1594@tanstack/ai-sandbox-cloudflare
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-cloudflare@1594@tanstack/ai-sandbox-daytona
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-daytona@1594@tanstack/ai-sandbox-docker
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-docker@1594@tanstack/ai-sandbox-e2b
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-e2b@1594@tanstack/ai-sandbox-local-process
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-local-process@1594@tanstack/ai-sandbox-sprites
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-sprites@1594@tanstack/ai-sandbox-upstash-box
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-upstash-box@1594@tanstack/ai-sandbox-vercel
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-sandbox-vercel@1594@tanstack/ai-skills
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-skills@1594@tanstack/ai-solid
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@1594@tanstack/ai-solid-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@1594@tanstack/ai-svelte
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-svelte@1594@tanstack/ai-typesafe
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-typesafe@1594@tanstack/ai-utils
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-utils@1594@tanstack/ai-vercel-gateway
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vercel-gateway@1594@tanstack/ai-vertex
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vertex@1594@tanstack/ai-vue
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue@1594@tanstack/ai-vue-ui
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-vue-ui@1594@tanstack/ai-worldlabs
npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-worldlabs@1594@tanstack/openai-base
npm i https://pkg.pr.new/TanStack/ai/@tanstack/openai-base@1594@tanstack/preact-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/preact-ai-devtools@1594@tanstack/react-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@1594@tanstack/solid-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@1594@tanstack/svelte-ai-devtools
npm i https://pkg.pr.new/TanStack/ai/@tanstack/svelte-ai-devtools@1594commit:
97c07cftombeckenham merged this02a998f
tombeckenham closed this
Sign in to join this conversation.
Note
Currently processing new changes in this PR. This may take a few minutes, please wait...
⚙️ Run configuration
02c02c20-ae11-4476-a285-463f6b262c8f📥 Commits
Reviewing files that changed from the base of the PR and between 2f22d58f508a4d049c43f6bffd62b67eb1833d18 and 97c07cf3d59a3005d4cde489eb46bd26b0167541.
📒 Files selected for processing (5)
docs/adapters/anthropic.mddocs/config.jsonpackages/ai-anthropic/src/text/text-provider-options.tspackages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.mdtesting/e2e/src/routeTree.gen.tsNo actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
239fe5c6-b45a-4d60-9e6a-95fe22b80d17📥 Commits
Reviewing files that changed from the base of the PR and between a441ecdf806d5f915eddc0a0c57763a5881e123e and 2f22d58f508a4d049c43f6bffd62b67eb1833d18.
📒 Files selected for processing (3)
.changeset/anthropic-sonnet-5-5-model-options.mddocs/adapters/anthropic.mdpackages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.
📝 Walkthrough
Walkthrough#
The adapter metadata and documentation now describe Claude Sonnet 5.5’s model-option and tool constraints. Type-safety tests cover those constraints. A new end-to-end wire-format test checks the captured request.
Changes#
Claude Sonnet 5.5 support
packages/ai-anthropic/src/model-meta.ts,packages/ai-anthropic/tests/chat-per-model-type-safety.test.ts,packages/ai-anthropic/tests/tools-per-model-type-safety.test.ts,docs/adapters/anthropic.md,docs/tools/provider-tools.md,packages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md,.changeset/anthropic-sonnet-5-5-model-options.mdoutput_configandmax_tokensbut exclude sampling options. Its supported tools exclude computer use. Type tests cover accepted and rejected options and tools. The documentation describes the model’s constraints, and the changeset records the patch.testing/e2e/src/routes/api.anthropic-sonnet-5-5-wire.ts,testing/e2e/src/routeTree.gen.ts,testing/e2e/tests/anthropic-sonnet-5-5-wire.spec.tsPriority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)#
Merge Risk: ⚪ Minimal · up to
2f22dThe adapter and request test reflect Sonnet 5.5’s documented option and tool constraints. No concrete regression is evident, so the change appears ready to merge subject to normal checks.
Architecture Summary#
Architecture risk: 🔵 Low · up to
2f22dThe change affects 4 systems.
Changed systems:
packages/ai-anthropic,testing,docs,packages/aiArchitecture concerns No architecture-level concerns identified.
Review details
Systems and components
Before / after behavior
computerUseTool, one model with no tool support, and the removal of retired Claude 3.x models with narrower support; previously it only noted the latter removal.computer_use; the surrounding comments state that its accepted tool version is not sent bycomputerUseTool().AnthropicSamplingOptionsand addsAnthropicMaxTokensOptions.🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
✨ 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.
❤️ Share