Preserve the client-agent header for Amazon Bedrock Runtime (#47964)

## What changed

Keep `x-amzn-mantle-client-agent: codex` in the Amazon Bedrock Runtime provider instead of clearing the headers inherited from the Amazon Bedrock provider.

## Testing

Update provider construction expectations and extend the API provider header test to cover both Amazon Bedrock providers.

GitOrigin-RevId: eab07f347b53f0a6ba2e224a39590f49f181363e
This commit is contained in:
Celia Chen
2026-09-24 23:24:02 +00:00
committed by copyberry
parent 8dd0a08160
commit 8f103417ef
2 changed files with 22 additions and 14 deletions
-1
View File
@@ -593,7 +593,6 @@ other non-default provider fields are not supported"
) -> ModelProviderInfo {
let mut provider = Self::create_amazon_bedrock_provider(aws);
provider.name = AMAZON_BEDROCK_RUNTIME_PROVIDER_NAME.into();
provider.http_headers = None;
provider
}
@@ -354,7 +354,6 @@ fn test_create_amazon_bedrock_provider() {
fn test_create_amazon_bedrock_runtime_provider() {
let mut expected = ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None);
expected.name = "Amazon Bedrock Runtime".to_string();
expected.http_headers = None;
assert_eq!(
ModelProviderInfo::create_amazon_bedrock_runtime_provider(/*aws*/ None),
@@ -387,7 +386,10 @@ fn test_create_amazon_bedrock_runtime_provider_with_aws_configuration() {
credential_export: None,
auth_refresh: None,
}),
None,
Some(maplit::hashmap! {
AMAZON_BEDROCK_MANTLE_CLIENT_AGENT_HEADER.to_string() =>
AMAZON_BEDROCK_MANTLE_CLIENT_AGENT_VALUE.into(),
}),
false,
)
);
@@ -407,18 +409,25 @@ fn provider_auth_for_test() -> ModelProviderAuthInfo {
}
#[test]
fn test_amazon_bedrock_provider_adds_mantle_client_agent_header() {
let api_provider = ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None)
.to_api_provider(/*auth_mode*/ None)
.expect("Amazon Bedrock provider should build API provider");
fn test_amazon_bedrock_providers_add_mantle_client_agent_header() {
for provider in [
ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None),
ModelProviderInfo::create_amazon_bedrock_runtime_provider(/*aws*/ None),
] {
let api_provider = provider
.to_api_provider(/*auth_mode*/ None)
.expect("Amazon Bedrock provider should build API provider");
assert_eq!(
api_provider
.headers
.get(AMAZON_BEDROCK_MANTLE_CLIENT_AGENT_HEADER)
.and_then(|value| value.to_str().ok()),
Some(AMAZON_BEDROCK_MANTLE_CLIENT_AGENT_VALUE)
);
assert_eq!(
api_provider
.headers
.get(AMAZON_BEDROCK_MANTLE_CLIENT_AGENT_HEADER)
.and_then(|value| value.to_str().ok()),
Some(AMAZON_BEDROCK_MANTLE_CLIENT_AGENT_VALUE),
"provider: {}",
provider.name
);
}
}
#[test]