mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
fix: Limit Bedrock GPT models to default service tier (#25318)
## Description Bedrock currently only supports the implicit `default` service tier for GPT models. This PR strips non-default service tier metadata from Bedrock model catalogs so Codex does not advertise or send unsupported tiers. ## What changed - Normalize both built-in and configured Bedrock catalogs to default-only service tier behavior. - Add regression coverage for built-in and configured Bedrock catalogs. ## Validation - `just fmt` - `just test -p codex-model-provider`
This commit is contained in:
committed by
GitHub
Unverified
parent
8acaec73b6
commit
966932124c
@@ -9,7 +9,7 @@ const GPT_5_5_OPENAI_MODEL_ID: &str = "gpt-5.5";
|
||||
const GPT_5_4_OPENAI_MODEL_ID: &str = "gpt-5.4";
|
||||
|
||||
pub(crate) fn static_model_catalog() -> ModelsResponse {
|
||||
ModelsResponse {
|
||||
with_default_only_service_tier(ModelsResponse {
|
||||
models: vec![
|
||||
gpt_5_bedrock_model(
|
||||
GPT_5_5_OPENAI_MODEL_ID,
|
||||
@@ -22,7 +22,17 @@ pub(crate) fn static_model_catalog() -> ModelsResponse {
|
||||
/*priority*/ 1,
|
||||
),
|
||||
],
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn with_default_only_service_tier(mut catalog: ModelsResponse) -> ModelsResponse {
|
||||
for model in &mut catalog.models {
|
||||
// Amazon Bedrock currently only supports the implicit "default" tier for GPT models.
|
||||
model.additional_speed_tiers.clear();
|
||||
model.service_tiers.clear();
|
||||
model.default_service_tier = None;
|
||||
}
|
||||
catalog
|
||||
}
|
||||
|
||||
fn gpt_5_bedrock_model(openai_slug: &str, bedrock_slug: &str, priority: i32) -> ModelInfo {
|
||||
@@ -45,6 +55,7 @@ fn bundled_openai_model(slug: &str) -> ModelInfo {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use super::*;
|
||||
@@ -87,4 +98,24 @@ mod tests {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gpt_5_bedrock_models_only_allow_default_service_tier() {
|
||||
let catalog = static_model_catalog();
|
||||
|
||||
for model in catalog.models {
|
||||
assert_eq!(model.additional_speed_tiers, Vec::<String>::new());
|
||||
assert_eq!(model.service_tiers, Vec::new());
|
||||
assert_eq!(model.default_service_tier, None);
|
||||
assert_eq!(
|
||||
model.service_tier_for_request(Some("priority".to_string())),
|
||||
None
|
||||
);
|
||||
assert_eq!(
|
||||
model
|
||||
.service_tier_for_request(Some(SERVICE_TIER_DEFAULT_REQUEST_VALUE.to_string())),
|
||||
None
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ use crate::provider::ProviderAccountState;
|
||||
use crate::provider::ProviderCapabilities;
|
||||
use auth::resolve_provider_auth;
|
||||
pub(crate) use catalog::static_model_catalog;
|
||||
use catalog::with_default_only_service_tier;
|
||||
use mantle::runtime_base_url;
|
||||
|
||||
/// Runtime provider for Amazon Bedrock's OpenAI-compatible Mantle endpoint.
|
||||
@@ -103,7 +104,7 @@ impl ModelProvider for AmazonBedrockModelProvider {
|
||||
) -> SharedModelsManager {
|
||||
Arc::new(StaticModelsManager::new(
|
||||
/*auth_manager*/ None,
|
||||
config_model_catalog.unwrap_or_else(static_model_catalog),
|
||||
config_model_catalog.map_or_else(static_model_catalog, with_default_only_service_tier),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -520,9 +520,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn amazon_bedrock_provider_uses_configured_static_catalog_when_present() {
|
||||
let custom_model =
|
||||
codex_models_manager::model_info::model_info_from_slug("custom-bedrock-model");
|
||||
async fn configured_bedrock_catalog_only_allows_default_service_tier() {
|
||||
let configured_model = codex_models_manager::bundled_models_response()
|
||||
.expect("bundled models should parse")
|
||||
.models
|
||||
.into_iter()
|
||||
.find(|model| model.slug == "gpt-5.5")
|
||||
.expect("bundled models should include GPT-5.5");
|
||||
assert!(!configured_model.additional_speed_tiers.is_empty());
|
||||
assert!(!configured_model.service_tiers.is_empty());
|
||||
|
||||
let provider = create_model_provider(
|
||||
ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None),
|
||||
@@ -531,14 +537,20 @@ mod tests {
|
||||
let manager = provider.models_manager(
|
||||
test_codex_home(),
|
||||
Some(ModelsResponse {
|
||||
models: vec![custom_model],
|
||||
models: vec![configured_model],
|
||||
}),
|
||||
);
|
||||
|
||||
let catalog = manager.raw_model_catalog(RefreshStrategy::Online).await;
|
||||
|
||||
assert_eq!(catalog.models.len(), 1);
|
||||
assert_eq!(catalog.models[0].slug, "custom-bedrock-model");
|
||||
assert_eq!(catalog.models[0].slug, "gpt-5.5");
|
||||
assert_eq!(
|
||||
catalog.models[0].additional_speed_tiers,
|
||||
Vec::<String>::new()
|
||||
);
|
||||
assert_eq!(catalog.models[0].service_tiers, Vec::new());
|
||||
assert_eq!(catalog.models[0].default_service_tier, None);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user