feat(models): adaptive thinking for Opus 4.6 - #2550
Conversation
Set reasoningMode adaptive on the Opus 4.6 anthropic, aws-bedrock and vertex-anthropic provider mappings so the gateway sends thinking type adaptive with output_config.effort instead of the legacy budget_tokens form, matching Opus 4.7/4.8 and enabling interleaved thinking. Adds a regression test covering 4.6/4.7/4.8. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR updates claude-opus-4-6 provider entries to declare adaptive reasoning ( ChangesAdaptive Reasoning Mode for Opus 4.6
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/actions/src/prepare-request-body.adaptive.spec.ts`:
- Line 49: Remove the "as any" cast on the test helper return (the expression
")) as any;") and replace it with a narrow, explicit type: declare the helper's
return type (or the variable it's assigned to) to the correct interface used by
the tests (e.g., RequestBody / PrepareRequestBodyResult) or use a generic helper
signature so callers infer the correct type; if the value is temporally untyped,
use "unknown" and then cast to the precise type at the point of use. Update the
helper function/mocked builder signature so the compiler enforces the concrete
type instead of bypassing type-checking with "as any", and adjust any test
callers to match the new typed return.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 8bef36a3-f1c8-4f62-a4f6-99b47c73220b
📒 Files selected for processing (2)
packages/actions/src/prepare-request-body.adaptive.spec.tspackages/models/src/models/anthropic.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2ad1ec7190
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| reasoningMode: "adaptive", | ||
| reasoningMaxTokens: true, |
There was a problem hiding this comment.
Stop advertising exact budgets for adaptive Opus 4.6
Marking this mapping as adaptive while leaving reasoningMaxTokens: true advertises support for an exact reasoning.max_tokens budget (the validator and auto-router key off that flag), but the adaptive branch in prepareRequestBody sends only thinking: { type: "adaptive" } and never forwards a budget. Requests that specify reasoning.max_tokens will now be accepted or auto-routed here but silently ignore the requested budget; match the 4.7/4.8 mappings by clearing the flag on all new adaptive 4.6 mappings, or translate the budget explicitly.
Useful? React with 👍 / 👎.
| contextSize: 1000000, | ||
| maxOutput: 128000, | ||
| reasoning: true, | ||
| reasoningMode: "adaptive", |
There was a problem hiding this comment.
Mark adaptive Opus 4.6 reasoning output as omitted
Adaptive thinking can skip emitting reasoning text, but leaving reasoningOutput undefined means the model metadata says reasoning output is expected by default (see ProviderModelMapping docs), and the gateway reasoning e2e checks use that flag. The existing Opus 4.7/4.8 adaptive mappings set reasoningOutput: "omit" for this reason; without the same setting here, 4.6 requests/tests that inspect the metadata can fail whenever the model chooses not to produce a thinking block.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b981be5b5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| maxOutput: 128000, | ||
| reasoning: true, | ||
| reasoningMaxTokens: true, | ||
| reasoningMode: "adaptive", |
There was a problem hiding this comment.
Preserve effort when enabling adaptive 4.6
For Anthropic/Vertex Opus 4.6 requests that combine reasoning_effort/effort with response_format: { type: "json_schema" }, this new adaptive mapping makes prepareRequestBody put the requested depth in requestBody.output_config.effort, but the later JSON-schema branch replaces output_config with only format. Before this change, 4.6 used thinking: { type: "enabled", budget_tokens } and did not depend on output_config.effort, so structured-output calls now silently lose the requested reasoning depth; merge the JSON-schema format into the existing output_config instead of overwriting it.
Useful? React with 👍 / 👎.
Enables adaptive thinking for Claude Opus 4.6 by setting
reasoningMode: "adaptive"on itsanthropic,aws-bedrock, andvertex-anthropicprovider mappings, so the gateway sendsthinking: { type: "adaptive" }withoutput_config.effortinstead of the legacybudget_tokensform — bringing 4.6 in line with Opus 4.7/4.8 and enabling interleaved thinking between tool calls. Adds a regression test asserting 4.6/4.7/4.8 build the adaptive thinking block. Note: for 4.6,reasoning.max_tokensnow routes to adaptive and the explicitbudget_tokensis dropped (Anthropic rejects it in adaptive mode), with depth controlled viaeffortinstead. Verified end-to-end through the gateway — 4.6 emits the adaptive payload, Anthropic accepts it, and thinking scales with prompt complexity (0 tokens on a trivial prompt vs 263 on a hard one at equal effort).🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
New Features
Documentation