mirror of
https://github.com/openai/codex.git
synced 2026-11-13 14:46:14 +00:00
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:
1 parent
18110b810f
commit
315195492c
20 files changed
+362
-148
No files matched your search
@@ -1755,7 +1755,6 @@ mod tests {
|
||||
use super::*;
|
||||
use anyhow::Result;
|
||||
use codex_protocol::ThreadId;
|
||||
use codex_protocol::account::AmazonBedrockCredentialSource;
|
||||
use codex_protocol::account::PlanType;
|
||||
use codex_protocol::config_types::MultiAgentMode;
|
||||
use codex_protocol::models::BUILT_IN_PERMISSION_PROFILE_READ_ONLY;
|
||||
@@ -2995,35 +2994,35 @@ mod tests {
|
||||
);
|
||||
|
||||
let codex_managed_bedrock = v2::Account::AmazonBedrock {
|
||||
credential_source: AmazonBedrockCredentialSource::CodexManaged,
|
||||
uses_codex_managed_credentials: true,
|
||||
};
|
||||
assert_eq!(
|
||||
json!({
|
||||
"type": "amazonBedrock",
|
||||
"credentialSource": "codexManaged",
|
||||
"usesCodexManagedCredentials": true,
|
||||
}),
|
||||
serde_json::to_value(&codex_managed_bedrock)?,
|
||||
);
|
||||
|
||||
let aws_managed_bedrock = v2::Account::AmazonBedrock {
|
||||
credential_source: AmazonBedrockCredentialSource::AwsManaged,
|
||||
let externally_managed_bedrock = v2::Account::AmazonBedrock {
|
||||
uses_codex_managed_credentials: false,
|
||||
};
|
||||
assert_eq!(
|
||||
json!({
|
||||
"type": "amazonBedrock",
|
||||
"credentialSource": "awsManaged",
|
||||
"usesCodexManagedCredentials": false,
|
||||
}),
|
||||
serde_json::to_value(&aws_managed_bedrock)?,
|
||||
serde_json::to_value(&externally_managed_bedrock)?,
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn account_defaults_legacy_bedrock_credential_source() -> Result<()> {
|
||||
fn account_defaults_legacy_bedrock_managed_credentials_flag() -> Result<()> {
|
||||
assert_eq!(
|
||||
v2::Account::AmazonBedrock {
|
||||
credential_source: AmazonBedrockCredentialSource::AwsManaged,
|
||||
uses_codex_managed_credentials: false,
|
||||
},
|
||||
serde_json::from_value(json!({
|
||||
"type": "amazonBedrock",
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user