Skip to content

Commit 7e17982

Browse files
feat(bedrock): allow global inference selection when cross-region is enabled (#9616)
Co-authored-by: Roo Code <[email protected]>
1 parent 3208f6f commit 7e17982

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/api/providers/__tests__/bedrock-inference-profiles.spec.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
})

webview-ui/src/components/settings/providers/Bedrock.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,21 +152,17 @@ export const Bedrock = ({ apiConfiguration, setApiConfigurationField, selectedMo
152152
{supportsGlobalInference && (
153153
<Checkbox
154154
checked={apiConfiguration?.awsUseGlobalInference || false}
155-
disabled={apiConfiguration?.awsUseCrossRegionInference || false}
156155
onChange={(checked: boolean) => {
157-
// Enabling Global Inference should disable cross-region inference
156+
// Global Inference takes priority over cross-region when both are enabled
158157
setApiConfigurationField("awsUseGlobalInference", checked)
159-
if (checked) setApiConfigurationField("awsUseCrossRegionInference", false)
160158
}}>
161159
{t("settings:providers.awsGlobalInference")}
162160
</Checkbox>
163161
)}
164162
<Checkbox
165163
checked={apiConfiguration?.awsUseCrossRegionInference || false}
166-
disabled={apiConfiguration?.awsUseGlobalInference || false}
167164
onChange={(checked: boolean) => {
168165
setApiConfigurationField("awsUseCrossRegionInference", checked)
169-
if (checked) setApiConfigurationField("awsUseGlobalInference", false)
170166
}}>
171167
{t("settings:providers.awsCrossRegion")}
172168
</Checkbox>

0 commit comments

Comments
 (0)