@@ -851,39 +851,179 @@ describe("ProviderTransform.providerOptions", () => {
851851 const binding = { prefixMismatchBehavior : "drop_block" }
852852 const claude = ( npm : string , id : string ) =>
853853 createModel ( { providerID : "custom" , api : { id, url : "https://example.com" , npm } } )
854+ const sdks = [
855+ { npm : "@ai-sdk/anthropic" , key : "anthropic" , option : "thinking" } ,
856+ { npm : "@ai-sdk/google-vertex/anthropic" , key : "anthropic" , option : "thinking" } ,
857+ { npm : "@ai-sdk/amazon-bedrock" , key : "bedrock" , option : "reasoningConfig" } ,
858+ ]
854859
855860 test ( "adds blockBinding to explicit adaptive thinking on @ai-sdk/anthropic" , ( ) => {
856- const model = claude ( "@ai-sdk/anthropic" , "claude-opus-4-7 " )
861+ const model = claude ( "@ai-sdk/anthropic" , "claude-fable-5-1 " )
857862 expect ( ProviderTransform . providerOptions ( model , { thinking : { type : "adaptive" } , effort : "high" } ) ) . toEqual ( {
858863 anthropic : { thinking : { type : "adaptive" , blockBinding : binding } , effort : "high" } ,
859864 } )
860865 } )
861866
862- test ( "adds blockBinding to explicit enabled thinking" , ( ) => {
863- const model = claude ( "@ai-sdk/anthropic" , "claude-sonnet -4-5" )
867+ test ( "leaves explicit enabled thinking on older models alone " , ( ) => {
868+ const model = claude ( "@ai-sdk/anthropic" , "claude-haiku -4-5" )
864869 expect ( ProviderTransform . providerOptions ( model , { thinking : { type : "enabled" , budgetTokens : 4000 } } ) ) . toEqual ( {
865- anthropic : { thinking : { type : "enabled" , budgetTokens : 4000 , blockBinding : binding } } ,
870+ anthropic : { thinking : { type : "enabled" , budgetTokens : 4000 } } ,
866871 } )
867872 } )
868873
869- test ( "injects adaptive thinking for models that think by default when no variant is set" , ( ) => {
870- for ( const id of [ "claude-fable-5-1" , "claude-mythos-5-1" , "claude-opus-5" , "claude-sonnet-5" ] ) {
871- const model = claude ( "@ai-sdk/anthropic" , id )
872- expect ( ProviderTransform . providerOptions ( model , { } ) ) . toEqual ( {
873- anthropic : { thinking : { type : "adaptive" , blockBinding : binding } } ,
874+ sdks . forEach ( ( sdk ) => {
875+ describe ( sdk . npm , ( ) => {
876+ test . each ( [
877+ "claude-fable-5-1" ,
878+ "claude-fable-5.1" ,
879+ "claude-5.1-fable" ,
880+ "global.anthropic.claude-fable-5-1" ,
881+ "us.anthropic.claude-fable-5-1-v1:0" ,
882+ "claude-fable-5-1@default" ,
883+ "CLAUDE-FABLE-5-1" ,
884+ "claude-opus-5-1" ,
885+ "claude-sonnet-5-2" ,
886+ "claude-mythos-5-2" ,
887+ "claude-mythos-5-10" ,
888+ "claude-opus-6" ,
889+ "claude-6-opus" ,
890+ "claude-mythos-6-20270901" ,
891+ ] ) ( "adds binding for %s" , ( id ) => {
892+ const model = claude ( sdk . npm , id )
893+ expect ( ProviderTransform . providerOptions ( model , { } ) ) . toEqual ( {
894+ [ sdk . key ] : { [ sdk . option ] : { type : "adaptive" , blockBinding : binding } } ,
895+ } )
896+ expect (
897+ ProviderTransform . providerOptions ( model , { [ sdk . option ] : { type : "adaptive" , display : "summarized" } } ) ,
898+ ) . toEqual ( {
899+ [ sdk . key ] : { [ sdk . option ] : { type : "adaptive" , display : "summarized" , blockBinding : binding } } ,
900+ } )
901+ expect (
902+ ProviderTransform . providerOptions ( model , { [ sdk . option ] : { type : "enabled" , budgetTokens : 4000 } } ) ,
903+ ) . toEqual ( {
904+ [ sdk . key ] : { [ sdk . option ] : { type : "enabled" , budgetTokens : 4000 , blockBinding : binding } } ,
905+ } )
906+ expect ( ProviderTransform . providerOptions ( model , { [ sdk . option ] : { type : "disabled" } } ) ) . toEqual ( {
907+ [ sdk . key ] : { [ sdk . option ] : { type : "disabled" } } ,
908+ } )
874909 } )
875- }
876- } )
877910
878- test ( "does not inject thinking for models that are off by default" , ( ) => {
879- for ( const id of [ "claude-opus-4-7" , "claude-opus-4-5" , "claude-sonnet-4-6" , "claude-haiku-4-5" ] ) {
880- const model = claude ( "@ai-sdk/anthropic" , id )
881- expect ( ProviderTransform . providerOptions ( model , { } ) ) . toEqual ( { anthropic : { } } )
882- }
911+ test . each ( [
912+ "claude-haiku-4-5" ,
913+ "claude-opus-4-8" ,
914+ "claude-sonnet-4-6" ,
915+ "claude-opus-5" ,
916+ "claude-sonnet-5" ,
917+ "claude-fable-5" ,
918+ "claude-opus-5-0" ,
919+ "claude-opus-5-20260724" ,
920+ "global.anthropic.claude-opus-5" ,
921+ "us.anthropic.claude-opus-5" ,
922+ "claude-sonnet-5@default" ,
923+ "claude-mythos-5-1" ,
924+ "claude-mythos-5.1" ,
925+ "claude-5.1-mythos" ,
926+ "global.anthropic.claude-mythos-5-1-v1:0" ,
927+ "claude-mythos-5-1@default" ,
928+ "CLAUDE-MYTHOS-5-1" ,
929+ "claude-future" ,
930+ ] ) ( "leaves thinking unchanged for %s" , ( id ) => {
931+ const model = claude ( sdk . npm , id )
932+ expect ( ProviderTransform . providerOptions ( model , { } ) ) . toEqual ( { [ sdk . key ] : { } } )
933+ expect (
934+ ProviderTransform . providerOptions ( model , { [ sdk . option ] : { type : "adaptive" , display : "summarized" } } ) ,
935+ ) . toEqual ( { [ sdk . key ] : { [ sdk . option ] : { type : "adaptive" , display : "summarized" } } } )
936+ expect (
937+ ProviderTransform . providerOptions ( model , { [ sdk . option ] : { type : "enabled" , budgetTokens : 4000 } } ) ,
938+ ) . toEqual ( { [ sdk . key ] : { [ sdk . option ] : { type : "enabled" , budgetTokens : 4000 } } } )
939+ } )
940+
941+ test . each ( [
942+ [ "claude-opus-5" , "default" ] ,
943+ [ "claude-opus-5" , "high" ] ,
944+ [ "claude-sonnet-5" , "default" ] ,
945+ [ "claude-sonnet-5" , "high" ] ,
946+ [ "claude-mythos-5-1" , "default" ] ,
947+ [ "claude-mythos-5-1" , "high" ] ,
948+ [ "claude-haiku-4-5" , "title" ] ,
949+ ] ) ( "omits binding from the %s %s request body and betas" , async ( id , mode ) => {
950+ const requests : Request [ ] = [ ]
951+ const capture = Object . assign (
952+ async ( ...args : Parameters < typeof fetch > ) => {
953+ requests . push ( new Request ( ...args ) )
954+ return Response . json (
955+ sdk . key === "bedrock"
956+ ? {
957+ output : { message : { role : "assistant" , content : [ { text : "ok" } ] } } ,
958+ stopReason : "end_turn" ,
959+ usage : { inputTokens : 1 , outputTokens : 1 , totalTokens : 2 } ,
960+ }
961+ : {
962+ type : "message" ,
963+ id : "msg_1" ,
964+ model : "test-model" ,
965+ role : "assistant" ,
966+ content : [ { type : "text" , text : "ok" } ] ,
967+ stop_reason : "end_turn" ,
968+ usage : { input_tokens : 1 , output_tokens : 1 } ,
969+ } ,
970+ )
971+ } ,
972+ { preconnect : ( ) => undefined } ,
973+ )
974+ const provider =
975+ sdk . key === "bedrock"
976+ ? createAmazonBedrock ( { apiKey : "test-key" , region : "ap-southeast-1" , fetch : capture } )
977+ : sdk . npm === "@ai-sdk/google-vertex/anthropic"
978+ ? createVertexAnthropic ( {
979+ project : "test-project" ,
980+ location : "global" ,
981+ generateAuthToken : async ( ) => "test-token" ,
982+ fetch : capture ,
983+ } )
984+ : createAnthropic ( { apiKey : "test-key" , fetch : capture } )
985+ const model = claude (
986+ sdk . npm ,
987+ sdk . key === "bedrock"
988+ ? `global.anthropic.${ id } `
989+ : sdk . npm === "@ai-sdk/google-vertex/anthropic"
990+ ? `${ id } @default`
991+ : id ,
992+ )
993+ const variants = ProviderTransform . variants ( model )
994+ const options =
995+ mode === "title"
996+ ? ProviderTransform . smallOptions ( { ...model , variants } )
997+ : mode === "high"
998+ ? variants . high
999+ : { }
1000+ await generateText ( {
1001+ model : provider ( model . api . id ) ,
1002+ prompt : "hi" ,
1003+ maxOutputTokens : 32000 ,
1004+ providerOptions : ProviderTransform . providerOptions ( model , options ) ,
1005+ } )
1006+ expect ( requests ) . toHaveLength ( 1 )
1007+ const body = await requests [ 0 ] . json ( )
1008+ const fields = sdk . key === "bedrock" ? ( body . additionalModelRequestFields ?? { } ) : body
1009+ expect ( fields . thinking ) . toEqual (
1010+ mode === "title"
1011+ ? { type : "enabled" , budget_tokens : 16000 }
1012+ : mode === "high"
1013+ ? { type : "adaptive" , display : "summarized" }
1014+ : undefined ,
1015+ )
1016+ expect ( fields . output_config ) . toEqual ( mode === "high" ? { effort : "high" } : undefined )
1017+ expect ( fields . anthropic_beta ?? [ ] ) . not . toContain ( "thinking-binding-controls-2026-08-01" )
1018+ expect ( requests [ 0 ] . headers . get ( "anthropic-beta" ) ?. split ( "," ) ?? [ ] ) . not . toContain (
1019+ "thinking-binding-controls-2026-08-01" ,
1020+ )
1021+ } )
1022+ } )
8831023 } )
8841024
8851025 test ( "leaves disabled thinking alone" , ( ) => {
886- const model = claude ( "@ai-sdk/anthropic" , "claude-sonnet-5 " )
1026+ const model = claude ( "@ai-sdk/anthropic" , "claude-fable-5-1 " )
8871027 expect ( ProviderTransform . providerOptions ( model , { thinking : { type : "disabled" } } ) ) . toEqual ( {
8881028 anthropic : { thinking : { type : "disabled" } } ,
8891029 } )
0 commit comments