feat: add Claude Opus 4.7 with adaptive thinking - #2018
Conversation
Remove the AWS Bedrock mapping (model ID is not yet available on Bedrock)
and wire up the new adaptive thinking API required by Claude Opus 4.7:
thinking: { type: "adaptive" } with output_config.effort, introduced via
a new reasoningMode provider flag so Opus 4.5/4.6 continue using the
legacy enabled/budget_tokens format.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
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 (4)
WalkthroughThis PR introduces support for Anthropic's adaptive thinking mode alongside the existing enabled thinking mode. It updates type definitions to support both modes, adds a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
Pull request overview
Adds Anthropic Claude Opus 4.7 to the model catalog and introduces an Anthropic-specific “adaptive thinking” request variant to support newer Opus models while preserving legacy thinking behavior for existing ones.
Changes:
- Extend Anthropic request types to support
thinking: { type: "adaptive" }and broadenoutput_config.effortvalues. - Add
reasoningModetoProviderModelMappingand use it in request preparation to choose between legacy vs adaptive thinking payloads. - Register the new
anthropic/claude-opus-4-7model with pricing tiers and capabilities.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/models/src/types.ts | Updates Anthropic request body typing for adaptive thinking + expanded effort values. |
| packages/models/src/models/anthropic.ts | Adds the Claude Opus 4.7 model definition and provider mapping (pricing, context, capabilities). |
| packages/models/src/models.ts | Introduces reasoningMode in ProviderModelMapping to select Anthropic thinking API variant. |
| packages/actions/src/prepare-request-body.ts | Implements adaptive thinking request formatting for Anthropic when reasoningMode === "adaptive". |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Opus 4.7+ uses adaptive thinking: `thinking: { type: "adaptive" }` with | ||
| // `output_config.effort` controlling depth. `budget_tokens` is rejected. | ||
| // The model decides whether to engage thinking based on prompt complexity. | ||
| requestBody.thinking = { type: "adaptive" }; | ||
| if (effort === undefined && reasoning_effort) { | ||
| const mapEffort = ( | ||
| e: typeof reasoning_effort, | ||
| ): "low" | "medium" | "high" | "xhigh" | "max" => { | ||
| switch (e) { | ||
| case "minimal": | ||
| case "low": | ||
| return "low"; | ||
| case "medium": | ||
| return "medium"; | ||
| case "high": | ||
| return "high"; | ||
| case "xhigh": | ||
| return "xhigh"; | ||
| default: | ||
| return "high"; | ||
| } | ||
| }; | ||
| requestBody.output_config ??= {}; | ||
| requestBody.output_config.effort = mapEffort(reasoning_effort); | ||
| } |
There was a problem hiding this comment.
In the adaptive-thinking branch, output_config.effort can be set from reasoning_effort even when the request-level effort param is undefined. Header injection for Anthropic’s effort beta currently keys off options.effort, so this path may send output_config.effort without the required anthropic-beta: effort-... header, causing the upstream API to reject or ignore the effort setting. Consider ensuring the header is added whenever requestBody.output_config.effort is present (or propagate a derived effort/flag back to the header builder).
| // Opus 4.7+ uses adaptive thinking: `thinking: { type: "adaptive" }` with | |
| // `output_config.effort` controlling depth. `budget_tokens` is rejected. | |
| // The model decides whether to engage thinking based on prompt complexity. | |
| requestBody.thinking = { type: "adaptive" }; | |
| if (effort === undefined && reasoning_effort) { | |
| const mapEffort = ( | |
| e: typeof reasoning_effort, | |
| ): "low" | "medium" | "high" | "xhigh" | "max" => { | |
| switch (e) { | |
| case "minimal": | |
| case "low": | |
| return "low"; | |
| case "medium": | |
| return "medium"; | |
| case "high": | |
| return "high"; | |
| case "xhigh": | |
| return "xhigh"; | |
| default: | |
| return "high"; | |
| } | |
| }; | |
| requestBody.output_config ??= {}; | |
| requestBody.output_config.effort = mapEffort(reasoning_effort); | |
| } | |
| // Opus 4.7+ uses adaptive thinking: `thinking: { type: "adaptive" }`. | |
| // Do not derive `output_config.effort` from `reasoning_effort` here: | |
| // Anthropic effort support also requires a matching beta header, and | |
| // header injection is keyed off the explicit request-level `effort`. | |
| requestBody.thinking = { type: "adaptive" }; |
| // Opus 4.7+ uses adaptive thinking: `thinking: { type: "adaptive" }` with | ||
| // `output_config.effort` controlling depth. `budget_tokens` is rejected. | ||
| // The model decides whether to engage thinking based on prompt complexity. | ||
| requestBody.thinking = { type: "adaptive" }; | ||
| if (effort === undefined && reasoning_effort) { |
There was a problem hiding this comment.
The new Anthropic reasoningMode === "adaptive" path (adaptive thinking + output_config.effort mapping) isn’t covered by unit tests in this package. Adding a focused test for the adaptive request shape would help prevent regressions in the payload formatting and effort mapping.
Summary
thinking: { type: "adaptive" }+output_config.effort) via a newreasoningModeflag onProviderModelMapping, so Opus 4.5/4.6 continue using the legacyenabled/budget_tokensformat.reasoningOutput: "omit"since adaptive thinking may skip thinking for simple prompts (by design).Bedrock mapping is not included — the model ID is not yet available on AWS Bedrock.
Test plan
TEST_MODELS="anthropic/claude-opus-4-7" pnpm test:e2e(all 72 tests pass)TEST_MODELS="anthropic/claude-opus-4-6" pnpm test:e2e(still passes, legacy path unchanged)pnpm buildpnpm format🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Updates