Conversation
…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>
|
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
📒 Files selected for processing (3)
🚧 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. 📝 WalkthroughWalkthroughThe 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. ChangesClaude Sonnet 5.5 support
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
Merge Risk: ⚪ Minimal · up to 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 SummaryArchitecture risk: 🔵 Low · up to The change affects 4 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 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. Comment |
|
Thanks for the PR, @ArVaViT! 🙌 @tombeckenham will take a look. Automated pre-review checks
Automated triage — a human review follows. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 2f22d58 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
On
claude-sonnet-5-5, the types accepttemperature,top_p,top_k, andcomputerUseTool(). The Claude API returns a 400 forcomputerUseTool()and for any non-default sampling value. The types also rejectoutput_config, so settingeffort, 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 wayclaude-opus-5-5andclaude-fable-5-1are 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.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.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().@tanstack/ai-anthropic.Sources: the Sonnet 5.5 overview ("Setting
temperature,top_p, ortop_kto a non-default value returns a 400 error"), and What's new in Claude Sonnet 5.5 ("supports computer use only through thecomputer_toolset_20260801toolset", 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
pnpm run test:pr, or these tests do not apply to this pull request.docs/for this change, or this change is not user-facing.pnpm changeset), or this PR does not change a published package.🚀 Release Impact
Root cause
Issue. On
claude-sonnet-5-5, the adapter types accepttemperature,top_p,top_k, andcomputerUseTool(). The Claude API returns a 400 forcomputerUseTool()and for any non-default sampling value.computerUseTool()sendscomputer_20241022orcomputer_20250124, and this model takes computer use only through thecomputer_toolset_20260801toolset. The types rejectoutput_config, so a caller cannot seteffortwithout a cast.Cause.
buildAnthropicProviderOptionsTypeinscripts/model-sync/provider-supports.tspicks the option mix from the OpenRouter catalog. The catalog liststemperatureforanthropic/claude-sonnet-5.5and marks reasoning as mandatory. So the function chose adaptive-only thinking plusAnthropicSamplingOptions, and it addsAnthropicOutputConfigOptionsonly when there is no sampling. That skips the rule in CONTRIBUTING: "reasoning.mandatory→AnthropicAdaptiveOnlyThinkingOptionsplusAnthropicOutputConfigOptions". The tool list is the genericANTHROPIC_SERVER_TOOLS, which includescomputer_use, while CONTRIBUTING says not to copy a tool list.Fix. Give
claude-sonnet-5-5the option mix thatclaude-fable-5-1has, with its adaptive-only thinking unchanged, and dropcomputer_useasclaude-opus-5-5does. The sync only inserts ids that are not in the file yet, so the hand edit survives later syncs.Possible alternatives
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.output_config. Smaller, buttemperaturewould still compile and fail at runtime.Testing
Commands run
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.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.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.Manual test
main, addmodelOptions: { output_config: { effort: 'medium' } }to achat()call withanthropicText('claude-sonnet-5-5').tscfails:output_configdoes not exist on the options type.pnpm --filter @tanstack/ai-anthropic test:types. It passes.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
claude-sonnet-5-5accepts and rejects, next to the cases for the other 5.x models.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, orcomputerUseTool()toclaude-sonnet-5-5now fails to compile. The API already rejected those requests, except sampling values equal to the default, which also stop compiling now. #884 narrowedclaude-sonnet-5the 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
After
🤖 Generated with Claude Code
Summary by CodeRabbit