@@ -3113,3 +3113,110 @@ describe("ProviderTransform.variants", () => {
31133113 } )
31143114 } )
31153115} )
3116+
3117+ describe ( "ProviderTransform.message - bedrock cache_point_ttl" , ( ) => {
3118+ const bedrockModel = {
3119+ id : "amazon-bedrock/anthropic.claude-opus-4-6" ,
3120+ providerID : "amazon-bedrock" ,
3121+ api : {
3122+ id : "anthropic.claude-opus-4-6" ,
3123+ url : "https://bedrock-runtime.us-east-1.amazonaws.com" ,
3124+ npm : "@ai-sdk/amazon-bedrock" ,
3125+ } ,
3126+ name : "Claude Opus 4.6" ,
3127+ capabilities : {
3128+ temperature : true ,
3129+ reasoning : false ,
3130+ attachment : true ,
3131+ toolcall : true ,
3132+ input : { text : true , audio : false , image : true , video : false , pdf : true } ,
3133+ output : { text : true , audio : false , image : false , video : false , pdf : false } ,
3134+ interleaved : false ,
3135+ } ,
3136+ cost : {
3137+ input : 0.003 ,
3138+ output : 0.015 ,
3139+ cache : { read : 0.0003 , write : 0.00375 } ,
3140+ } ,
3141+ limit : {
3142+ context : 200000 ,
3143+ output : 8192 ,
3144+ } ,
3145+ status : "active" ,
3146+ options : { } ,
3147+ headers : { } ,
3148+ } as any
3149+
3150+ test ( "should add ttl to bedrock cachePoint when cache_point_ttl is set to 5m" , ( ) => {
3151+ const msgs = [
3152+ {
3153+ role : "system" ,
3154+ content : "You are a helpful assistant." ,
3155+ } ,
3156+ {
3157+ role : "user" ,
3158+ content : "Hello" ,
3159+ } ,
3160+ ] as any [ ]
3161+
3162+ const result = ProviderTransform . message ( msgs , bedrockModel , { cache_point_ttl : "5m" } )
3163+
3164+ expect ( result ) . toHaveLength ( 2 )
3165+ expect ( result [ 0 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3166+ type : "default" ,
3167+ ttl : "5m" ,
3168+ } )
3169+ expect ( result [ 1 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3170+ type : "default" ,
3171+ ttl : "5m" ,
3172+ } )
3173+ } )
3174+
3175+ test ( "should add ttl to bedrock cachePoint when cache_point_ttl is set to 1h" , ( ) => {
3176+ const msgs = [
3177+ {
3178+ role : "system" ,
3179+ content : "You are a helpful assistant." ,
3180+ } ,
3181+ {
3182+ role : "user" ,
3183+ content : "Hello" ,
3184+ } ,
3185+ ] as any [ ]
3186+
3187+ const result = ProviderTransform . message ( msgs , bedrockModel , { cache_point_ttl : "1h" } )
3188+
3189+ expect ( result ) . toHaveLength ( 2 )
3190+ expect ( result [ 0 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3191+ type : "default" ,
3192+ ttl : "1h" ,
3193+ } )
3194+ expect ( result [ 1 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3195+ type : "default" ,
3196+ ttl : "1h" ,
3197+ } )
3198+ } )
3199+
3200+ test ( "should not add ttl to bedrock cachePoint when cache_point_ttl is not set" , ( ) => {
3201+ const msgs = [
3202+ {
3203+ role : "system" ,
3204+ content : "You are a helpful assistant." ,
3205+ } ,
3206+ {
3207+ role : "user" ,
3208+ content : "Hello" ,
3209+ } ,
3210+ ] as any [ ]
3211+
3212+ const result = ProviderTransform . message ( msgs , bedrockModel , { } )
3213+
3214+ expect ( result ) . toHaveLength ( 2 )
3215+ expect ( result [ 0 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3216+ type : "default" ,
3217+ } )
3218+ expect ( result [ 1 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3219+ type : "default" ,
3220+ } )
3221+ } )
3222+ } )
0 commit comments