@@ -13,6 +13,7 @@ import {
1313import {
1414 requiresClaudeDefaultSampling ,
1515 resolveClaudeMythos5ModelIdentity ,
16+ resolveClaudeOpus5ModelIdentity ,
1617 resolveClaudeSonnet5ModelIdentity ,
1718} from "openclaw/plugin-sdk/provider-model-shared" ;
1819import { buildGuardedModelFetch } from "openclaw/plugin-sdk/provider-transport-runtime" ;
@@ -37,6 +38,10 @@ function isClaudeSonnet5Model(model: Model): boolean {
3738 return resolveClaudeSonnet5ModelIdentity ( model ) !== undefined ;
3839}
3940
41+ function isClaudeOpus5Model ( model : Model ) : boolean {
42+ return resolveClaudeOpus5ModelIdentity ( model ) !== undefined ;
43+ }
44+
4045function requiresDefaultSampling ( model : Model ) : boolean {
4146 return requiresClaudeDefaultSampling ( model ) ;
4247}
@@ -69,11 +74,14 @@ function resolveMantleReasoning(
6974 if ( model . id . includes ( "claude-opus-4-7" ) ) {
7075 return undefined ;
7176 }
72- const sonnet5 = isClaudeSonnet5Model ( model ) ;
77+ // Sonnet 5 and Opus 5 default thinking on and keep it enabled on Bedrock,
78+ // matching resolveBedrockNativeThinkingLevelMap's off->low remap.
79+ const adaptiveDefaultClaude5 = isClaudeSonnet5Model ( model ) || isClaudeOpus5Model ( model ) ;
7380 const mythosPreview = isClaudeMythosPreviewModel ( model ) ;
7481 const mandatoryMythos = isClaudeMythos5Model ( model ) || mythosPreview ;
75- const reasoning = options ?. reasoning ?? ( mandatoryMythos || sonnet5 ? "high" : undefined ) ;
76- if ( sonnet5 ) {
82+ const reasoning =
83+ options ?. reasoning ?? ( mandatoryMythos || adaptiveDefaultClaude5 ? "high" : undefined ) ;
84+ if ( adaptiveDefaultClaude5 ) {
7785 return reasoning === "off" || reasoning === "minimal" ? "low" : reasoning ;
7886 }
7987 if ( ! mandatoryMythos ) {
@@ -85,7 +93,7 @@ function resolveMantleReasoning(
8593 return mythosPreview && ( reasoning === "xhigh" || reasoning === "max" ) ? "high" : reasoning ;
8694}
8795
88- function mapSonnet5Effort (
96+ function mapClaude5Effort (
8997 reasoning : NonNullable < SimpleStreamOptions [ "reasoning" ] > ,
9098) : "low" | "medium" | "high" | "xhigh" | "max" {
9199 if ( reasoning === "minimal" || reasoning === "low" ) {
@@ -118,7 +126,7 @@ function buildMantleAnthropicBaseOptions(
118126 ...( requiresDefaultSampling ( model ) ? { } : { temperature : options ?. temperature } ) ,
119127 maxTokens :
120128 options ?. maxTokens ||
121- ( isClaudeSonnet5Model ( model ) || isClaudeMythos5Model ( model )
129+ ( isClaudeSonnet5Model ( model ) || isClaudeOpus5Model ( model ) || isClaudeMythos5Model ( model )
122130 ? model . maxTokens
123131 : Math . min ( model . maxTokens , 32_000 ) ) ,
124132 signal : options ?. signal ,
@@ -185,7 +193,7 @@ export function createMantleAnthropicStreamFn(deps?: {
185193 // The client API is the same, but the SDK class private field makes types nominal.
186194 const streamClient = client as unknown as Anthropic ;
187195 const reasoning = resolveMantleReasoning ( model , options ) ;
188- const sonnet5 = isClaudeSonnet5Model ( model ) ;
196+ const claude5Effort = isClaudeSonnet5Model ( model ) || isClaudeOpus5Model ( model ) ;
189197 const mythos5 = isClaudeMythos5Model ( model ) ;
190198 if ( ! reasoning || reasoning === "off" ) {
191199 return streamFn ( model as Model < "anthropic-messages" > , context , {
@@ -195,12 +203,12 @@ export function createMantleAnthropicStreamFn(deps?: {
195203 } ) ;
196204 }
197205
198- if ( sonnet5 || mythos5 ) {
206+ if ( claude5Effort || mythos5 ) {
199207 return streamFn ( model as Model < "anthropic-messages" > , context , {
200208 ...base ,
201209 client : streamClient ,
202210 thinkingEnabled : true ,
203- effort : sonnet5 ? mapSonnet5Effort ( reasoning ) : reasoning ,
211+ effort : claude5Effort ? mapClaude5Effort ( reasoning ) : reasoning ,
204212 } ) ;
205213 }
206214
0 commit comments