@@ -3331,3 +3331,110 @@ describe("ProviderTransform.variants", () => {
33313331 } )
33323332 } )
33333333} )
3334+
3335+ describe ( "ProviderTransform.message - bedrock cache_point_ttl" , ( ) => {
3336+ const bedrockModel = {
3337+ id : "amazon-bedrock/anthropic.claude-opus-4-6" ,
3338+ providerID : "amazon-bedrock" ,
3339+ api : {
3340+ id : "anthropic.claude-opus-4-6" ,
3341+ url : "https://bedrock-runtime.us-east-1.amazonaws.com" ,
3342+ npm : "@ai-sdk/amazon-bedrock" ,
3343+ } ,
3344+ name : "Claude Opus 4.6" ,
3345+ capabilities : {
3346+ temperature : true ,
3347+ reasoning : false ,
3348+ attachment : true ,
3349+ toolcall : true ,
3350+ input : { text : true , audio : false , image : true , video : false , pdf : true } ,
3351+ output : { text : true , audio : false , image : false , video : false , pdf : false } ,
3352+ interleaved : false ,
3353+ } ,
3354+ cost : {
3355+ input : 0.003 ,
3356+ output : 0.015 ,
3357+ cache : { read : 0.0003 , write : 0.00375 } ,
3358+ } ,
3359+ limit : {
3360+ context : 200000 ,
3361+ output : 8192 ,
3362+ } ,
3363+ status : "active" ,
3364+ options : { } ,
3365+ headers : { } ,
3366+ } as any
3367+
3368+ test ( "should add ttl to bedrock cachePoint when cache_point_ttl is set to 5m" , ( ) => {
3369+ const msgs = [
3370+ {
3371+ role : "system" ,
3372+ content : "You are a helpful assistant." ,
3373+ } ,
3374+ {
3375+ role : "user" ,
3376+ content : "Hello" ,
3377+ } ,
3378+ ] as any [ ]
3379+
3380+ const result = ProviderTransform . message ( msgs , bedrockModel , { cache_point_ttl : "5m" } )
3381+
3382+ expect ( result ) . toHaveLength ( 2 )
3383+ expect ( result [ 0 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3384+ type : "default" ,
3385+ ttl : "5m" ,
3386+ } )
3387+ expect ( result [ 1 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3388+ type : "default" ,
3389+ ttl : "5m" ,
3390+ } )
3391+ } )
3392+
3393+ test ( "should add ttl to bedrock cachePoint when cache_point_ttl is set to 1h" , ( ) => {
3394+ const msgs = [
3395+ {
3396+ role : "system" ,
3397+ content : "You are a helpful assistant." ,
3398+ } ,
3399+ {
3400+ role : "user" ,
3401+ content : "Hello" ,
3402+ } ,
3403+ ] as any [ ]
3404+
3405+ const result = ProviderTransform . message ( msgs , bedrockModel , { cache_point_ttl : "1h" } )
3406+
3407+ expect ( result ) . toHaveLength ( 2 )
3408+ expect ( result [ 0 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3409+ type : "default" ,
3410+ ttl : "1h" ,
3411+ } )
3412+ expect ( result [ 1 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3413+ type : "default" ,
3414+ ttl : "1h" ,
3415+ } )
3416+ } )
3417+
3418+ test ( "should not add ttl to bedrock cachePoint when cache_point_ttl is not set" , ( ) => {
3419+ const msgs = [
3420+ {
3421+ role : "system" ,
3422+ content : "You are a helpful assistant." ,
3423+ } ,
3424+ {
3425+ role : "user" ,
3426+ content : "Hello" ,
3427+ } ,
3428+ ] as any [ ]
3429+
3430+ const result = ProviderTransform . message ( msgs , bedrockModel , { } )
3431+
3432+ expect ( result ) . toHaveLength ( 2 )
3433+ expect ( result [ 0 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3434+ type : "default" ,
3435+ } )
3436+ expect ( result [ 1 ] . providerOptions ?. bedrock ?. cachePoint ) . toEqual ( {
3437+ type : "default" ,
3438+ } )
3439+ } )
3440+ } )
0 commit comments