mirror of
https://github.com/openai/codex.git
synced 2026-11-25 15:24:26 +00:00
Enable cached web search for Amazon Bedrock (#36938)
## Why Amazon Bedrock supports hosted text web search, but it rejects the `search_content_types` field used for multimodal search and does not support external live or indexed web access. ## What changed - Advertise hosted web search for Amazon Bedrock while marking external web access as unsupported. - Resolve unsupported live and indexed modes to cached search, or disable the tool when cached search is prohibited by managed requirements. - Normalize built-in and configured Bedrock model catalogs to text-only web search, and retain the runtime provider in session configuration so turn setup can apply its capabilities. ## Testing - Cover cached fallback, managed-mode restrictions, text-only tool payloads, provider capabilities, and catalog normalization. GitOrigin-RevId: 310473849257401654388a4ebb42920e03aa3228
This commit is contained in:
1 parent
1e59dc5bda
commit
3ca9f375aa
13 files changed
+365
-50
No files matched your search
@@ -9,6 +9,7 @@ use codex_protocol::openai_models::ModelVisibility;
|
||||
use codex_protocol::openai_models::ModelsResponse;
|
||||
use codex_protocol::openai_models::ReasoningEffort;
|
||||
use codex_protocol::openai_models::ReasoningEffortPreset;
|
||||
use codex_protocol::openai_models::WebSearchToolType;
|
||||
|
||||
const GPT_5_BEDROCK_CONTEXT_WINDOW: i64 = 272_000;
|
||||
const GPT_5_6_SOL_OPENAI_MODEL_ID: &str = "gpt-5.6-sol";
|
||||
@@ -18,7 +19,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 {
|
||||
with_default_only_service_tier(ModelsResponse {
|
||||
normalize_bedrock_catalog(ModelsResponse {
|
||||
models: vec![
|
||||
gpt_5_6_bedrock_model(
|
||||
GPT_5_6_SOL_OPENAI_MODEL_ID,
|
||||
@@ -54,12 +55,14 @@ pub(crate) fn static_model_catalog() -> ModelsResponse {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn with_default_only_service_tier(mut catalog: ModelsResponse) -> ModelsResponse {
|
||||
pub(crate) fn normalize_bedrock_catalog(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;
|
||||
// Bedrock rejects the `search_content_types` field used by multimodal search.
|
||||
model.web_search_tool_type = WebSearchToolType::Text;
|
||||
}
|
||||
catalog
|
||||
}
|
||||
@@ -149,15 +152,39 @@ mod tests {
|
||||
|
||||
for model in catalog.models {
|
||||
assert_eq!(
|
||||
(model.context_window, model.max_context_window),
|
||||
(
|
||||
model.context_window,
|
||||
model.max_context_window,
|
||||
model.web_search_tool_type,
|
||||
),
|
||||
(
|
||||
Some(GPT_5_BEDROCK_CONTEXT_WINDOW),
|
||||
Some(GPT_5_BEDROCK_CONTEXT_WINDOW)
|
||||
Some(GPT_5_BEDROCK_CONTEXT_WINDOW),
|
||||
WebSearchToolType::Text,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_bedrock_catalogs_normalize_unsupported_model_capabilities() {
|
||||
let model = bundled_openai_model(GPT_5_4_OPENAI_MODEL_ID);
|
||||
let mut expected = model.clone();
|
||||
expected.additional_speed_tiers.clear();
|
||||
expected.service_tiers.clear();
|
||||
expected.default_service_tier = None;
|
||||
expected.web_search_tool_type = WebSearchToolType::Text;
|
||||
|
||||
assert_eq!(
|
||||
normalize_bedrock_catalog(ModelsResponse {
|
||||
models: vec![model],
|
||||
}),
|
||||
ModelsResponse {
|
||||
models: vec![expected],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gpt_5_bedrock_models_do_not_include_availability_nux_or_upgrade() {
|
||||
let catalog = static_model_catalog();
|
||||
|
||||
@@ -30,8 +30,8 @@ use crate::provider::ProviderAccountResult;
|
||||
use crate::provider::ProviderAccountState;
|
||||
use crate::provider::ProviderCapabilities;
|
||||
use auth::resolve_provider_auth as resolve_bedrock_provider_auth;
|
||||
use catalog::normalize_bedrock_catalog;
|
||||
pub(crate) use catalog::static_model_catalog;
|
||||
use catalog::with_default_only_service_tier;
|
||||
use mantle::bedrock_mantle_runtime_base_url;
|
||||
pub use mantle::is_supported_amazon_bedrock_region;
|
||||
|
||||
@@ -124,7 +124,8 @@ impl ModelProvider for AmazonBedrockModelProvider {
|
||||
ProviderCapabilities {
|
||||
namespace_tools: true,
|
||||
image_generation: false,
|
||||
web_search: false,
|
||||
web_search: true,
|
||||
external_web_access: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,7 +185,7 @@ impl ModelProvider for AmazonBedrockModelProvider {
|
||||
) -> SharedModelsManager {
|
||||
Arc::new(StaticModelsManager::new(
|
||||
/*auth_manager*/ None,
|
||||
config_model_catalog.map_or_else(static_model_catalog, with_default_only_service_tier),
|
||||
config_model_catalog.map_or_else(static_model_catalog, normalize_bedrock_catalog),
|
||||
))
|
||||
}
|
||||
|
||||
@@ -194,7 +195,7 @@ impl ModelProvider for AmazonBedrockModelProvider {
|
||||
) -> SharedModelsManager {
|
||||
Arc::new(StaticModelsManager::new(
|
||||
/*auth_manager*/ None,
|
||||
config_model_catalog.map_or_else(static_model_catalog, with_default_only_service_tier),
|
||||
config_model_catalog.map_or_else(static_model_catalog, normalize_bedrock_catalog),
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -354,7 +355,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn capabilities_disable_unsupported_hosted_tools() {
|
||||
fn capabilities_enable_web_search_but_disable_image_generation() {
|
||||
let provider = AmazonBedrockModelProvider::new(
|
||||
ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None),
|
||||
/*auth_manager*/ None,
|
||||
@@ -365,7 +366,8 @@ mod tests {
|
||||
ProviderCapabilities {
|
||||
namespace_tools: true,
|
||||
image_generation: false,
|
||||
web_search: false,
|
||||
web_search: true,
|
||||
external_web_access: false,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user