fix(reasoning): use adaptive thinking for Claude 4.7+ models#14816
Closed
Raymond8196 wants to merge 3 commits into
Closed
fix(reasoning): use adaptive thinking for Claude 4.7+ models#14816Raymond8196 wants to merge 3 commits into
Raymond8196 wants to merge 3 commits into
Conversation
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>
ed4b135 to
c167e9d
Compare
ousugo
reviewed
May 4, 2026
Collaborator
ousugo
left a comment
There was a problem hiding this comment.
发现 1 个需要补强的点:这次 4.6+ 识别修复缺少针对 Claude 4.7 / Bedrock 4.7 的回归测试,建议补上真实 model id 的断言以锁住修复路径。
ousugo
approved these changes
May 4, 2026
5 tasks
Signed-off-by: raymond <13162938362@163.com>
Collaborator
|
may be fixed: #14349 |
|
Confirmed the fix #14349 works. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 theeffortparameter, 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()inutils.tsused a regex that only matched4-6/4.6. Claude Opus 4.7 failed this check and fell through to the oldenabled+budgetTokenscode path, which Opus 4.7 does not support (returns HTTP 400).The fix expands the regex from
4[.-]6to4[.-](?:[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 theenabled+budgetTokensapproach).The following tradeoffs were made:
isClaude47SeriesModel()function, since the adaptive thinking API is the same for both 4.6 and 4.7+.The following alternatives were considered:
isClaude47SeriesModel()check — rejected as unnecessary duplication since both 4.6 and 4.7 use the same adaptive thinking API.Breaking changes
None.
Special notes for your reviewer
All 4 call sites of
isClaude46SeriesModel()benefit from this change:reasoning.ts:732— Usesadaptive+effortinstead ofenabled+budgetTokensreasoning.ts:956— Bedrock adaptive thinking (same logic)modelParameters.ts:146— Skips budget subtraction from maxTokensreasoning.ts:136— UI displaysclaude46effort options (includesxhigh)Checklist
/gh-pr-review,gh pr diff, or GitHub UI) before requesting review from othersRelease note