Skip to content

feat: add Claude Opus 4.7 with adaptive thinking - #2018

Merged
steebchen merged 2 commits into
mainfrom
add-opus-4-7
Apr 16, 2026
Merged

steebchen merged 2 commits into
mainfrom
add-opus-4-7

Conversation

@steebchen

@steebchen steebchen commented Apr 16, 2026

Copy link
Copy Markdown
Member

Summary

  • Add Claude Opus 4.7 via the Anthropic provider with full pricing (standard + >200K tier), 1M context / 128K output, vision, tools, web search, and JSON schema support.
  • Introduce adaptive thinking API support (thinking: { type: "adaptive" } + output_config.effort) via a new reasoningMode flag on ProviderModelMapping, so Opus 4.5/4.6 continue using the legacy enabled / budget_tokens format.
  • Mark the provider 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)
  • Regression: TEST_MODELS="anthropic/claude-opus-4-6" pnpm test:e2e (still passes, legacy path unchanged)
  • pnpm build
  • pnpm format

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for adaptive thinking mode for Anthropic reasoning models, which intelligently skips thinking on simpler tasks.
    • Introduced Claude Opus 4.7 model with adaptive reasoning, streaming, vision, tools, and web search capabilities.
  • Updates

    • Expanded effort level options for reasoning to include additional settings (xhigh and max).
    • Reasoning configuration now supports both traditional enabled mode and new adaptive mode variants.

steebchen and others added 2 commits April 16, 2026 22:56
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>
Copilot AI review requested due to automatic review settings April 16, 2026 16:16
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Apr 16, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b97f8537-aa6d-4dff-985c-28e3aa5f1e8c

📥 Commits

Reviewing files that changed from the base of the PR and between b4b953f and a5e55cd.

📒 Files selected for processing (4)
  • packages/actions/src/prepare-request-body.ts
  • packages/models/src/models.ts
  • packages/models/src/models/anthropic.ts
  • packages/models/src/types.ts

Walkthrough

This 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 reasoningMode field to provider mappings, implements conditional logic in request preparation to handle each mode differently, and introduces the claude-opus-4-7 model with adaptive reasoning capabilities.

Changes

Cohort / File(s) Summary
Type Definitions
packages/models/src/types.ts, packages/models/src/models.ts
Updated AnthropicRequestBody.thinking to support discriminated union of "enabled" (with budget_tokens) and "adaptive" modes. Expanded effort enum to include "xhigh" and "max". Added optional reasoningMode field to ProviderModelMapping interface to control which thinking variant is used.
Request Preparation Logic
packages/actions/src/prepare-request-body.ts
Enhanced Anthropic thinking logic to conditionally check providerMapping?.reasoningMode: when "adaptive", sets thinking: { type: "adaptive" } and conditionally maps reasoning_effort to output_config.effort via discrete scale; otherwise preserves prior "enabled" mode with budget_tokens behavior.
Model Configuration
packages/models/src/models/anthropic.ts
Added new model definition for claude-opus-4-7 with reasoningMode: "adaptive" and reasoning: true, including pricing tiers, token caching, context limits, streaming, vision, tools, and web search capabilities.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • smakosh
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding Claude Opus 4.7 model support with adaptive thinking capability, which is the primary focus of the changeset.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add-opus-4-7

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 and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 broaden output_config.effort values.
  • Add reasoningMode to ProviderModelMapping and use it in request preparation to choose between legacy vs adaptive thinking payloads.
  • Register the new anthropic/claude-opus-4-7 model 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.

Comment on lines +1327 to +1351
// 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);
}

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
// 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" };

Copilot uses AI. Check for mistakes.
Comment on lines +1327 to +1331
// 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) {

Copilot AI Apr 16, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@steebchen
steebchen merged commit 24a6b79 into main Apr 16, 2026
21 of 22 checks passed
@steebchen
steebchen deleted the add-opus-4-7 branch April 16, 2026 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants