diff --git a/src/api/providers/__tests__/bedrock-inference-profiles.spec.ts b/src/api/providers/__tests__/bedrock-inference-profiles.spec.ts index b2ac5b57e2f..dee3af3b916 100644 --- a/src/api/providers/__tests__/bedrock-inference-profiles.spec.ts +++ b/src/api/providers/__tests__/bedrock-inference-profiles.spec.ts @@ -254,5 +254,46 @@ describe("Amazon Bedrock Inference Profiles", () => { const usModel = usHandler.getModel() expect(usModel.id).toBe("us.anthropic.claude-3-sonnet-20240229-v1:0") }) + + it("should prioritize global inference over cross-region inference when both are enabled", () => { + // When both global inference and cross-region inference are enabled, + // global inference should take precedence + const handler = createHandler({ + awsUseCrossRegionInference: true, + awsUseGlobalInference: true, + awsRegion: "us-east-1", + apiModelId: "anthropic.claude-sonnet-4-20250514-v1:0", // Model that supports global inference + }) + + const model = handler.getModel() + // Should use global. prefix, not us. prefix + expect(model.id).toBe("global.anthropic.claude-sonnet-4-20250514-v1:0") + }) + + it("should fall back to cross-region inference when global inference is disabled", () => { + const handler = createHandler({ + awsUseCrossRegionInference: true, + awsUseGlobalInference: false, + awsRegion: "us-east-1", + apiModelId: "anthropic.claude-sonnet-4-20250514-v1:0", + }) + + const model = handler.getModel() + // Should use cross-region prefix since global is disabled + expect(model.id).toBe("us.anthropic.claude-sonnet-4-20250514-v1:0") + }) + + it("should not apply global inference prefix to unsupported models even when enabled", () => { + const handler = createHandler({ + awsUseCrossRegionInference: true, + awsUseGlobalInference: true, + awsRegion: "us-east-1", + apiModelId: "anthropic.claude-3-sonnet-20240229-v1:0", // Model that does NOT support global inference + }) + + const model = handler.getModel() + // Should fall back to cross-region prefix since model doesn't support global inference + expect(model.id).toBe("us.anthropic.claude-3-sonnet-20240229-v1:0") + }) }) }) diff --git a/webview-ui/src/components/settings/providers/Bedrock.tsx b/webview-ui/src/components/settings/providers/Bedrock.tsx index 2564eda3e54..d23eb5752a3 100644 --- a/webview-ui/src/components/settings/providers/Bedrock.tsx +++ b/webview-ui/src/components/settings/providers/Bedrock.tsx @@ -152,21 +152,17 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo {supportsGlobalInference && ( { - // Enabling Global Inference should disable cross-region inference + // Global Inference takes priority over cross-region when both are enabled setApiConfigurationField("awsUseGlobalInference", checked) - if (checked) setApiConfigurationField("awsUseCrossRegionInference", false) }}> {t("settings:providers.awsGlobalInference")} )} { setApiConfigurationField("awsUseCrossRegionInference", checked) - if (checked) setApiConfigurationField("awsUseGlobalInference", false) }}> {t("settings:providers.awsCrossRegion")}