@@ -254,5 +254,46 @@ describe("Amazon Bedrock Inference Profiles", () => {
254254 const usModel = usHandler . getModel ( )
255255 expect ( usModel . id ) . toBe ( "us.anthropic.claude-3-sonnet-20240229-v1:0" )
256256 } )
257+
258+ it ( "should prioritize global inference over cross-region inference when both are enabled" , ( ) => {
259+ // When both global inference and cross-region inference are enabled,
260+ // global inference should take precedence
261+ const handler = createHandler ( {
262+ awsUseCrossRegionInference : true ,
263+ awsUseGlobalInference : true ,
264+ awsRegion : "us-east-1" ,
265+ apiModelId : "anthropic.claude-sonnet-4-20250514-v1:0" , // Model that supports global inference
266+ } )
267+
268+ const model = handler . getModel ( )
269+ // Should use global. prefix, not us. prefix
270+ expect ( model . id ) . toBe ( "global.anthropic.claude-sonnet-4-20250514-v1:0" )
271+ } )
272+
273+ it ( "should fall back to cross-region inference when global inference is disabled" , ( ) => {
274+ const handler = createHandler ( {
275+ awsUseCrossRegionInference : true ,
276+ awsUseGlobalInference : false ,
277+ awsRegion : "us-east-1" ,
278+ apiModelId : "anthropic.claude-sonnet-4-20250514-v1:0" ,
279+ } )
280+
281+ const model = handler . getModel ( )
282+ // Should use cross-region prefix since global is disabled
283+ expect ( model . id ) . toBe ( "us.anthropic.claude-sonnet-4-20250514-v1:0" )
284+ } )
285+
286+ it ( "should not apply global inference prefix to unsupported models even when enabled" , ( ) => {
287+ const handler = createHandler ( {
288+ awsUseCrossRegionInference : true ,
289+ awsUseGlobalInference : true ,
290+ awsRegion : "us-east-1" ,
291+ apiModelId : "anthropic.claude-3-sonnet-20240229-v1:0" , // Model that does NOT support global inference
292+ } )
293+
294+ const model = handler . getModel ( )
295+ // Should fall back to cross-region prefix since model doesn't support global inference
296+ expect ( model . id ) . toBe ( "us.anthropic.claude-3-sonnet-20240229-v1:0" )
297+ } )
257298 } )
258299} )
0 commit comments