Skip to content

fix(reasoning): use adaptive thinking for Claude 4.7+ models#14816

Closed
Raymond8196 wants to merge 3 commits into
CherryHQ:mainfrom
Raymond8196:hotfix/fix-opus-4.7-adaptive-thinking
Closed

fix(reasoning): use adaptive thinking for Claude 4.7+ models#14816
Raymond8196 wants to merge 3 commits into
CherryHQ:mainfrom
Raymond8196:hotfix/fix-opus-4.7-adaptive-thinking

Conversation

@Raymond8196
Copy link
Copy Markdown
Contributor

@Raymond8196 Raymond8196 commented May 3, 2026

What this PR does

Before this PR:

Claude Opus 4.7 (claude-opus-4-7) fails with HTTP 400 when reasoning effort is set to any non-default value (low, medium, high). The error message: "thinking.type.enabled" is not supported for this model. Use "thinking.type.adaptive" and "output_config.effort" to control thinking behavior.

After this PR:

Claude Opus 4.7 correctly uses thinking: { type: "adaptive" } with the effort parameter, matching the Anthropic API requirements.

Fixes #14805
Fixes #14821

Why we need it and why it was done in this way

The root cause is that isClaude46SeriesModel() in utils.ts used a regex that only matched 4-6/4.6. Claude Opus 4.7 failed this check and fell through to the old enabled + budgetTokens code path, which Opus 4.7 does not support (returns HTTP 400).

The fix expands the regex from 4[.-]6 to 4[.-](?:[6-9]|\d{2,}) to match Claude 4.6+ models. This is the minimal change that fixes the issue and is forward-compatible with future 4.8, 4.9 releases, which are expected to continue using adaptive thinking (Anthropic is deprecating the enabled + budgetTokens approach).

The following tradeoffs were made:

  • Chose to match all 4.6+ versions rather than adding a separate isClaude47SeriesModel() function, since the adaptive thinking API is the same for both 4.6 and 4.7+.

The following alternatives were considered:

  • Adding a separate isClaude47SeriesModel() check — rejected as unnecessary duplication since both 4.6 and 4.7 use the same adaptive thinking API.

Note: Some proxy APIs may automatically convert enabled + budget_tokens to adaptive parameters, masking this issue. Users connecting directly to the Anthropic API or AWS Bedrock are affected.

Breaking changes

None.

Special notes for your reviewer

All 4 call sites of isClaude46SeriesModel() benefit from this change:

  1. reasoning.ts:732 — Uses adaptive + effort instead of enabled + budgetTokens
  2. reasoning.ts:956 — Bedrock adaptive thinking (same logic)
  3. modelParameters.ts:146 — Skips budget subtraction from maxTokens
  4. reasoning.ts:136 — UI displays claude46 effort options (includes xhigh)

Checklist

Release note

Fix Claude Opus 4.7 returning HTTP 400 when reasoning effort is set to non-default values. The model now correctly uses adaptive thinking parameters instead of the unsupported extended thinking format.

Claude Opus 4.7 only supports thinking.type: "adaptive" with effort
parameter. The previous regex in isClaude46SeriesModel only matched
4.6 models, causing 4.7 to fall through to the "enabled" +
budgetTokens path which returns HTTP 400.

Expand the regex to match Claude 4.6+ (4.6, 4.7, 4.8, ...) so all
future models default to adaptive thinking.

Closes CherryHQ#14805

Signed-off-by: raymond <13162938362@163.com>
…n isClaude46SeriesModel

Signed-off-by: raymond <13162938362@163.com>
@Raymond8196 Raymond8196 force-pushed the hotfix/fix-opus-4.7-adaptive-thinking branch from ed4b135 to c167e9d Compare May 3, 2026 16:39
Copy link
Copy Markdown
Collaborator

@ousugo ousugo left a comment

Choose a reason for hiding this comment

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

发现 1 个需要补强的点:这次 4.6+ 识别修复缺少针对 Claude 4.7 / Bedrock 4.7 的回归测试,建议补上真实 model id 的断言以锁住修复路径。

Comment thread src/renderer/src/config/models/utils.ts
@DeJeune
Copy link
Copy Markdown
Collaborator

DeJeune commented May 7, 2026

may be fixed: #14349

@cloudy-sfu
Copy link
Copy Markdown

Confirmed the fix #14349 works.

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.

[Bug]: Incorrect reasoning params passed for OpenRouter claude-opus-4.7 [Bug]: Claude Opus 4.7 thinking mode used wrong parameters

4 participants