Support custom transports for Amazon Bedrock (#33695)

## What changed

- Allow the built-in `amazon-bedrock` provider to override `base_url`, `auth`,
  and `http_headers` in addition to its AWS profile and region.
- Use command-based bearer authentication and configured endpoints without
  applying AWS request signing, while retaining regional endpoint resolution
  for the default Bedrock configuration.
- Replace the Bedrock account `credentialSource` enum with the
  `usesCodexManagedCredentials` boolean so command-authenticated and other
  externally managed configurations are reported consistently.

## Testing

- Cover configuration merging and validation, command-authenticated proxy
  requests with custom headers, and account reporting for managed and external
  credentials.

GitOrigin-RevId: d1acbe602060470583b5e12f8d304bee5be46f4c
This commit is contained in:
Celia Chen authored and copyberry committed 2026-07-16 21:41:00 +00:00
1 parent 18110b810f
commit 315195492c
20 files changed
+362 -148

No files matched your search

@@ -1,6 +1,5 @@
use crate::protocol::common::AuthMode;
use codex_experimental_api_macros::ExperimentalApi;
use codex_protocol::account::AmazonBedrockCredentialSource;
use codex_protocol::account::PlanType;
use codex_protocol::account::ProviderAccount;
use codex_protocol::protocol::CreditsSnapshot as CoreCreditsSnapshot;
@@ -34,8 +33,8 @@ pub enum Account {
#[serde(rename = "amazonBedrock", rename_all = "camelCase")]
#[ts(rename = "amazonBedrock", rename_all = "camelCase")]
AmazonBedrock {
#[serde(default = "default_bedrock_credential_source")]
credential_source: AmazonBedrockCredentialSource,
#[serde(default)]
uses_codex_managed_credentials: bool,
},
}
@@ -45,18 +44,16 @@ fn nullable_string_schema(
generator.subschema_for::<Option<String>>()
}
fn default_bedrock_credential_source() -> AmazonBedrockCredentialSource {
AmazonBedrockCredentialSource::AwsManaged
}
impl From<ProviderAccount> for Account {
fn from(account: ProviderAccount) -> Self {
match account {
ProviderAccount::ApiKey => Self::ApiKey {},
ProviderAccount::Chatgpt { email, plan_type } => Self::Chatgpt { email, plan_type },
ProviderAccount::AmazonBedrock { credential_source } => {
Self::AmazonBedrock { credential_source }
}
ProviderAccount::AmazonBedrock {
uses_codex_managed_credentials,
} => Self::AmazonBedrock {
uses_codex_managed_credentials,
},
}
}
}