From d4a475adda850d80b6149c76454de94e0cf4fd51 Mon Sep 17 00:00:00 2001 From: alexsong-oai Date: Wed, 30 Sep 2026 23:35:22 +0000 Subject: [PATCH] Support AWS GovCloud regions for Amazon Bedrock Mantle (#49813) ## Why Codex rejected `us-gov-east-1` and `us-gov-west-1` as unsupported Amazon Bedrock regions. ## What changed Accept both GovCloud regions and construct their regional Bedrock Mantle endpoint URLs. ## Testing Extend the endpoint URL unit test to cover both GovCloud regions alongside the existing `ap-northeast-1` case. GitOrigin-RevId: ef9ca83fa7b73af1df100fcae722e24edac38643 --- .../src/amazon_bedrock/mantle.rs | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/codex-rs/model-provider/src/amazon_bedrock/mantle.rs b/codex-rs/model-provider/src/amazon_bedrock/mantle.rs index a4148a8395..9406c6b7ea 100644 --- a/codex-rs/model-provider/src/amazon_bedrock/mantle.rs +++ b/codex-rs/model-provider/src/amazon_bedrock/mantle.rs @@ -23,6 +23,7 @@ const BEDROCK_MANTLE_SUPPORTED_REGIONS: [&str; 12] = [ "eu-north-1", "sa-east-1", ]; +const BEDROCK_GOV_CLOUD_SUPPORTED_REGIONS: [&str; 2] = ["us-gov-east-1", "us-gov-west-1"]; pub(super) fn aws_auth_config(aws: &ModelProviderAwsAuthInfo) -> AwsAuthConfig { AwsAuthConfig { @@ -43,6 +44,7 @@ pub(super) fn region_from_config(aws: &ModelProviderAwsAuthInfo) -> Option bool { BEDROCK_MANTLE_SUPPORTED_REGIONS.contains(®ion) + || BEDROCK_GOV_CLOUD_SUPPORTED_REGIONS.contains(®ion) } pub(super) fn base_url(region: &str) -> Result { @@ -80,10 +82,22 @@ mod tests { #[test] fn base_url_uses_region_endpoint() { - assert_eq!( - base_url("ap-northeast-1").expect("supported region"), - "https://bedrock-mantle.ap-northeast-1.api.aws/openai/v1" - ); + for (region, expected) in [ + ( + "ap-northeast-1", + "https://bedrock-mantle.ap-northeast-1.api.aws/openai/v1", + ), + ( + "us-gov-east-1", + "https://bedrock-mantle.us-gov-east-1.api.aws/openai/v1", + ), + ( + "us-gov-west-1", + "https://bedrock-mantle.us-gov-west-1.api.aws/openai/v1", + ), + ] { + assert_eq!(base_url(region).expect("supported region"), expected); + } } #[test]