@@ -706,17 +706,29 @@ function anthropicBindsThinking(apiId: string) {
706706const ANTHROPIC_BLOCK_BINDING = { prefixMismatchBehavior : "drop_block" }
707707
708708function anthropicBlockBinding ( model : Provider . Model , options : { [ x : string ] : any } ) {
709+ const sdk = sdkKey ( model . api . npm )
710+ const key = sdk === "bedrock" ? "reasoningConfig" : sdk === "anthropic" ? "thinking" : undefined
711+ // Consume the OpenCode-only opt-out even on models outside the default scope.
712+ if ( key && options [ key ] ?. blockBinding === false ) {
713+ const result = { ...options , [ key ] : { ...options [ key ] } }
714+ delete result [ key ] . blockBinding
715+ if ( Object . keys ( result [ key ] ) . length === 0 ) delete result [ key ]
716+ return result
717+ }
718+
709719 if ( ! anthropicBindsThinking ( model . api . id ) ) return options
710720 switch ( model . api . npm ) {
711721 case "@ai-sdk/anthropic" :
712722 case "@ai-sdk/google-vertex/anthropic" : {
713723 const thinking = options . thinking ?? { type : "adaptive" }
714724 if ( thinking . type !== "adaptive" && thinking . type !== "enabled" ) return options
725+ if ( thinking . blockBinding !== undefined ) return options
715726 return { ...options , thinking : { ...thinking , blockBinding : ANTHROPIC_BLOCK_BINDING } }
716727 }
717728 case "@ai-sdk/amazon-bedrock" : {
718729 const reasoningConfig = options . reasoningConfig ?? { type : "adaptive" }
719730 if ( reasoningConfig . type !== "adaptive" && reasoningConfig . type !== "enabled" ) return options
731+ if ( reasoningConfig . blockBinding !== undefined ) return options
720732 return { ...options , reasoningConfig : { ...reasoningConfig , blockBinding : ANTHROPIC_BLOCK_BINDING } }
721733 }
722734 }
0 commit comments