Skip to content

fix(ai-anthropic): match claude-sonnet-5-5 options and tools to the Claude API - #1594

Open
ArVaViT wants to merge 2 commits into
TanStack:mainfrom
ArVaViT:fix/anthropic-sonnet-5-5-model-options
Open

ArVaViT wants to merge 2 commits into
TanStack:mainfrom
ArVaViT:fix/anthropic-sonnet-5-5-model-options

Conversation

@ArVaViT

@ArVaViT ArVaViT commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

On 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-5 takes AnthropicMaxTokensOptions and AnthropicOutputConfigOptions in place of AnthropicSamplingOptions, in both the satisfies ModelMeta clause and AnthropicChatModelProviderOptionsByName. computer_use leaves its tool list, with the same comment as claude-opus-5-5. The other six provider tools stay.
  • model-meta.ts comments: one above the constant and one in the options map, like the hand-set claude-fable-5 and claude-sonnet-5 entries.
  • Tests: a claude-sonnet-5-5 block in chat-per-model-type-safety.test.ts and two cases in tools-per-model-type-safety.test.ts, written like the claude-fable-5 and claude-opus-5-5 cases. A new E2E route and spec (anthropic-sonnet-5-5-wire) send output_config.effort through the adapter and check the request.
  • Docs and skill reference: Sonnet 5.5 joins the per-model rules, effort, and output_config lists in docs/adapters/anthropic.md and in the adapter-configuration Anthropic reference. The computer use lines in docs/adapters/anthropic.md and docs/tools/provider-tools.md now name the models that do not take computerUseTool().
  • 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 AnthropicOutputConfigOptions whenever reasoning is mandatory, as CONTRIBUTING says, and stop writing computer_use for new models. That covers future models too, but the catalog still lists temperature here, 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, but temperature would still compile and fail at runtime.

Testing

Commands run

  • On main (3a09cf044), the new type tests fail tsc with 8 errors: output_config is rejected twice (the call and the toHaveProperty check), two @ts-expect-error lines for temperature and top_k are unused, the three not.toHaveProperty checks for sampling fail, and the computerUseTool() @ts-expect-error is unused. On this branch, tsc passes. The disabled and budget_tokens cases pass on both: main already types this model's thinking as adaptive-only, and the cases keep it that way.
  • On main, the new E2E route fails tsc: 'output_config' does not exist in type ... AnthropicSamplingOptions. On this branch, tsc for testing/e2e passes, and playwright 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 uses claude-sonnet-5-5.
  • I reverted each hunk of model-meta.ts in turn. Each one makes tsc fail.
  • @tanstack/ai-anthropic: unit tests 175 passed, test:oxlint clean, tsc clean. @tanstack/ai-code-mode-snippets (the only package that depends on it): tsc clean. test:docs and test:kiira pass. I did not run pnpm test:pr itself: on my machine its Nx build step starts the Playwright browser download, which hangs.

Manual test

  1. On main, add modelOptions: { output_config: { effort: 'medium' } } to a chat() call with anthropicText('claude-sonnet-5-5'). tsc fails: output_config does not exist on the options type.
  2. On this branch, run pnpm --filter @tanstack/ai-anthropic test:types. It passes.
  3. In the claude-sonnet-5-5 block of chat-per-model-type-safety.test.ts, remove the @ts-expect-error above temperature. tsc now fails, because the model rejects sampling values.

How this PR makes testing easy

  • The type tests list what claude-sonnet-5-5 accepts and rejects, next to the cases for the other 5.x models.
  • The E2E route does not compile if the model loses output_config again, and the spec checks that effort reaches 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_choice any / tool return a 400 on this model, claude-opus-5-5, and claude-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, and supported Anthropic provider tools.
  • Documentation
    • Clarified that Sonnet 5.5 does not accept sampling settings or budget-based thinking, and does not support computer use through the available adapter tool.
    • Documented that computer use is also unavailable for Claude Opus 5.5.

…laude API

The model sync (TanStack#1516) typed claude-sonnet-5-5 with the sampling options,
without output_config, and with computer_use. The Claude API rejects
non-default temperature/top_p/top_k and the computer_20250124-era tools on
this model with a 400, and effort lives under output_config.

- Provider options: AnthropicMaxTokensOptions & AnthropicOutputConfigOptions
  in place of AnthropicSamplingOptions, like claude-fable-5-1
- Tools: computer_use removed, like claude-opus-5-5
- Type tests, an E2E wire route and spec, docs, the adapter-configuration
  skill reference, and a changeset

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: TanStack/ai/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 239fe5c6-b45a-4d60-9e6a-95fe22b80d17
📥 Commits

Reviewing files that changed from the base of the PR and between a441ecd and 2f22d58.

📒 Files selected for processing (3)
  • .changeset/anthropic-sonnet-5-5-model-options.md
  • docs/adapters/anthropic.md
  • packages/ai/skills/ai-core/adapter-configuration/references/anthropic-adapter.md
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/anthropic-sonnet-5-5-model-options.md
  • docs/adapters/anthropic.md

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

Layer / File(s) Summary
Model options and tool constraints
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.md
Sonnet 5.5 uses adaptive-only thinking and provider options that include output_config and max_tokens but 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.
Wire-format validation
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.ts
The new route captures a Sonnet 5.5 request and returns a synthetic Anthropic stream. The end-to-end test checks the model, effort, token limit, and web-search tool type.

Priority: ➖ Normal

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

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant WireFormatTest
  participant POSTRoute
  participant chat
  participant customFetch
  WireFormatTest->>POSTRoute: POST wire-format request
  POSTRoute->>chat: Run Sonnet 5.5 with medium effort, max_tokens, and web search
  chat->>customFetch: Send provider request
  customFetch->>customFetch: Capture request body
  customFetch-->>chat: Return synthetic Anthropic text stream
  POSTRoute->>WireFormatTest: Return captured request
  WireFormatTest->>WireFormatTest: Assert model, effort, token limit, and tool type
Loading

Merge Risk: ⚪ Minimal · up to 2f22d

The 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 2f22d

The change affects 4 systems.

Changed systems: packages/ai-anthropic, testing, docs, packages/ai

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/ai-anthropic (library) was modified; 3 changed files map to changed impact.
  • observed — testing (service) was modified; 3 changed files map to changed impact.
  • observed — docs (service) was modified; 2 changed files map to changed impact.
  • observed — packages/ai (library) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in docs/tools/provider-tools.md: The Anthropic support description now identifies two models that lack 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.
  • observed — Modified behavior in packages/ai-anthropic/src/model-meta.ts: Added comments describing Sonnet 5.5’s stated rejection of disabled or budget-based thinking and non-default sampling parameters, and its adaptive-only, no-sampling provider-option shape.
  • observed — Modified behavior in packages/ai-anthropic/src/model-meta.ts: Sonnet 5.5’s supported tools no longer include computer_use; the surrounding comments state that its accepted tool version is not sent by computerUseTool().
  • observed — Modified behavior in packages/ai-anthropic/src/model-meta.ts: Sonnet 5.5’s provider-option type drops AnthropicSamplingOptions and adds AnthropicMaxTokensOptions.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 6 files. (3 skipped: 3 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: aligning Claude Sonnet 5.5 options and tools with the Claude API.
Description check ✅ Passed The description covers the changes, root cause, alternatives, testing, risks, and release impact. It follows the template and clearly states that the full test command was not run.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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 Oct 2, 2026

Copy link
Copy Markdown
Contributor

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

Automated triage — a human review follows.

@github-actions github-actions Bot added the waiting-on: maintainer The ball is in the maintainers’ court label Oct 2, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2f22d58

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on: maintainer The ball is in the maintainers’ court

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants