@@ -53,6 +53,7 @@ import {
5353 type ToolResultMessage ,
5454} from "openclaw/plugin-sdk/llm" ;
5555import {
56+ isClaudeAdaptiveThinkingDefaultModelId ,
5657 resolveClaudeFable5ModelIdentity ,
5758 resolveClaudeModelIdentity ,
5859 supportsClaudeAdaptiveThinking ,
@@ -351,29 +352,38 @@ export const streamSimpleBedrock: StreamFunction<"bedrock-converse-stream", Simp
351352 model : Model < "bedrock-converse-stream" > ,
352353 context : Context ,
353354 options ?: SimpleStreamOptions ,
354- ) => {
355+ ) => streamBedrock ( model , context , resolveSimpleBedrockOptions ( model , options ) ) ;
356+
357+ function resolveSimpleBedrockOptions (
358+ model : Model < "bedrock-converse-stream" > ,
359+ options ?: SimpleStreamOptions ,
360+ ) : BedrockOptions {
355361 const base = buildBaseOptions ( model , options , undefined ) ;
356362 if ( usesClaudeFable5BedrockContract ( model ) ) {
357- return streamBedrock ( model , context , {
363+ return {
358364 ...base ,
359365 reasoning : options ?. reasoning ?? "high" ,
360366 thinkingBudgets : options ?. thinkingBudgets ,
361- } satisfies BedrockOptions ) ;
367+ } satisfies BedrockOptions ;
362368 }
363369 if ( ! options ?. reasoning ) {
364- return streamBedrock ( model , context , {
370+ const reasoning =
371+ isAnthropicClaudeModel ( model ) && requiresMandatoryAdaptiveThinking ( model )
372+ ? "high"
373+ : undefined ;
374+ return {
365375 ...base ,
366- reasoning : undefined ,
367- } satisfies BedrockOptions ) ;
376+ reasoning,
377+ } satisfies BedrockOptions ;
368378 }
369379
370380 if ( isAnthropicClaudeModel ( model ) ) {
371381 if ( supportsAdaptiveThinking ( model ) ) {
372- return streamBedrock ( model , context , {
382+ return {
373383 ...base ,
374384 reasoning : options . reasoning ,
375385 thinkingBudgets : options . thinkingBudgets ,
376- } satisfies BedrockOptions ) ;
386+ } satisfies BedrockOptions ;
377387 }
378388
379389 // Undefined means the caller did not request an output cap; let the helper use the model cap.
@@ -385,23 +395,23 @@ export const streamSimpleBedrock: StreamFunction<"bedrock-converse-stream", Simp
385395 options . thinkingBudgets ,
386396 ) ;
387397
388- return streamBedrock ( model , context , {
398+ return {
389399 ...base ,
390400 maxTokens : adjusted . maxTokens ,
391401 reasoning : options . reasoning ,
392402 thinkingBudgets : {
393403 ...options . thinkingBudgets ,
394404 [ clampReasoning ( options . reasoning ) ! ] : adjusted . thinkingBudget ,
395405 } ,
396- } satisfies BedrockOptions ) ;
406+ } satisfies BedrockOptions ;
397407 }
398408
399- return streamBedrock ( model , context , {
409+ return {
400410 ...base ,
401411 reasoning : options . reasoning ,
402412 thinkingBudgets : options . thinkingBudgets ,
403- } satisfies BedrockOptions ) ;
404- } ;
413+ } satisfies BedrockOptions ;
414+ }
405415
406416function handleContentBlockStart (
407417 event : ContentBlockStartEvent ,
@@ -565,6 +575,14 @@ function supportsAdaptiveThinking(model: Model<"bedrock-converse-stream">): bool
565575 ) ;
566576}
567577
578+ function requiresMandatoryAdaptiveThinking ( model : Model < "bedrock-converse-stream" > ) : boolean {
579+ const profileModelId = resolveClaudeProfileNameModelId ( model . name ) ;
580+ return (
581+ isClaudeAdaptiveThinkingDefaultModelId ( resolveClaudeModelIdentity ( model ) ) ||
582+ ( profileModelId ? isClaudeAdaptiveThinkingDefaultModelId ( profileModelId ) : false )
583+ ) ;
584+ }
585+
568586function supportsNativeXhighEffort ( model : Model < "bedrock-converse-stream" > ) : boolean {
569587 const profileModelId = resolveClaudeProfileNameModelId ( model . name ) ;
570588 return (
@@ -1071,9 +1089,11 @@ function createImageBlock(mimeType: string, data: string) {
10711089
10721090/** Test-only hooks for Bedrock runtime conversion and endpoint policy. */
10731091export const testing = {
1092+ buildAdditionalModelRequestFields,
10741093 convertMessages,
10751094 getConfiguredBedrockRegion,
10761095 hasConfiguredBedrockProfile,
10771096 mapThinkingLevelToEffort,
1097+ resolveSimpleBedrockOptions,
10781098 shouldUseExplicitBedrockEndpoint,
10791099} ;
0 commit comments