From 1759ac249ad405ba201a134a2d4b434223f99b20 Mon Sep 17 00:00:00 2001 From: Abhinav Date: Wed, 2 Dec 2026 03:18:33 +0000 Subject: [PATCH] Inherit bundled tool capabilities on Amazon Bedrock (#65184) ## Why The Bedrock catalog cleared the bundled tool mode, so models configured for Code Mode did not get that default on Bedrock. Runtime inference profiles also discarded the base model's tool search capability. ## What changed - Inherit the bundled tool mode on standard Bedrock endpoints. Leave the mode unset for GPT-5.5 and GovCloud Mantle so Code Mode settings determine tool exposure there. - Inherit model-level tool search support in global and US cross-region Runtime inference profiles. - Keep full Responses requests so Mantle can expose cached web search alongside Code Mode. ## Testing Add coverage for Runtime profile capability inheritance and GovCloud Mantle defaults. Verify that GPT-5.6 Sol on Mantle sends both `functions.exec` and the text-only cached web search tool. GitOrigin-RevId: dca35b5ca08321b5a906b442dbcbdec648ffdcea --- codex-rs/core/tests/suite/web_search.rs | 19 ++- .../src/amazon_bedrock/catalog.rs | 18 +- .../model-provider/src/amazon_bedrock/mod.rs | 24 +++ .../src/amazon_bedrock/runtime_catalog.rs | 1 - .../amazon_bedrock/runtime_catalog_tests.rs | 155 +++--------------- 5 files changed, 81 insertions(+), 136 deletions(-) diff --git a/codex-rs/core/tests/suite/web_search.rs b/codex-rs/core/tests/suite/web_search.rs index 92fe45833f..d648069705 100644 --- a/codex-rs/core/tests/suite/web_search.rs +++ b/codex-rs/core/tests/suite/web_search.rs @@ -6,6 +6,7 @@ use codex_features::Feature; use codex_login::CodexAuth; use codex_login::auth::BedrockApiKeyAuth; use codex_model_provider_info::AMAZON_BEDROCK_GPT_5_5_MODEL_ID; +use codex_model_provider_info::AMAZON_BEDROCK_GPT_5_6_SOL_MODEL_ID; use codex_model_provider_info::AMAZON_BEDROCK_PROVIDER_ID; use codex_model_provider_info::AMAZON_BEDROCK_RUNTIME_PROVIDER_ID; use codex_model_provider_info::ModelProviderInfo; @@ -75,11 +76,13 @@ async fn amazon_bedrock_web_search_uses_text_only_hosted_tools() { enum ModelCatalog { BuiltIn, + BuiltInCodeMode, Configured, } for (case, config_toml, model_catalog) in [ ("cached by default", "", ModelCatalog::BuiltIn), + ("cached with Code Mode", "", ModelCatalog::BuiltInCodeMode), ( "unsupported explicit live search falls back to cached", "web_search = \"live\"", @@ -119,6 +122,9 @@ async fn amazon_bedrock_web_search_uses_text_only_hosted_tools() { }); builder = match model_catalog { ModelCatalog::BuiltIn => builder.with_model(AMAZON_BEDROCK_GPT_5_5_MODEL_ID), + ModelCatalog::BuiltInCodeMode => { + builder.with_model(AMAZON_BEDROCK_GPT_5_6_SOL_MODEL_ID) + } ModelCatalog::Configured => builder.with_model_info_override("gpt-5.5", |model_info| { model_info.web_search_tool_type = WebSearchToolType::TextAndImage; }), @@ -142,7 +148,18 @@ async fn amazon_bedrock_web_search_uses_text_only_hosted_tools() { .await .expect("submit Bedrock turn"); - let body = resp_mock.single_request().body_json(); + let request = resp_mock.single_request(); + let body = request.body_json(); + if matches!(model_catalog, ModelCatalog::BuiltInCodeMode) { + assert!( + request + .inputs_of_type("additional_tools") + .iter() + .any( + |item| responses::namespace_child_tool(item, "functions", "exec").is_some() + ) + ); + } assert_eq!( find_web_search_tool(&body), &json!({ diff --git a/codex-rs/model-provider/src/amazon_bedrock/catalog.rs b/codex-rs/model-provider/src/amazon_bedrock/catalog.rs index 454703ec7c..1d7aa3de23 100644 --- a/codex-rs/model-provider/src/amazon_bedrock/catalog.rs +++ b/codex-rs/model-provider/src/amazon_bedrock/catalog.rs @@ -94,6 +94,8 @@ pub(crate) fn static_model_catalog() -> ModelsResponse { "GPT-5.6 Luna", /*priority*/ 9, ), + // GPT-5.5 has no bundled tool mode. Inherit that unset value so + // the user's Code Mode settings determine how tools are exposed. gpt_5_bedrock_model( GPT_5_5_OPENAI_MODEL_ID, AMAZON_BEDROCK_GPT_5_5_MODEL_ID, @@ -113,6 +115,9 @@ pub(super) fn static_gov_model_catalog() -> ModelsResponse { AMAZON_BEDROCK_GPT_5_6_TERRA_MODEL_ID | AMAZON_BEDROCK_GPT_5_6_LUNA_MODEL_ID ) }); + for model in &mut catalog.models { + model.tool_mode = None; + } catalog } @@ -192,8 +197,8 @@ fn bedrock_model( model.visibility = ModelVisibility::List; model.availability_nux = None; model.upgrade = None; + // Codex omits hosted tools in Lite, including Mantle's cached web search. model.use_responses_lite = false; - model.tool_mode = None; model } @@ -435,7 +440,17 @@ mod tests { "GPT-6-Astra", 4, ), + ( + bundled_openai_model(GPT_5_5_OPENAI_MODEL_ID), + AMAZON_BEDROCK_GPT_5_5_MODEL_ID, + "GPT-5.5", + 10, + ), ] { + if slug == AMAZON_BEDROCK_GPT_5_5_MODEL_ID { + expected.context_window = Some(GPT_5_BEDROCK_CONTEXT_WINDOW); + expected.max_context_window = Some(GPT_5_BEDROCK_CONTEXT_WINDOW); + } expected.slug = slug.to_string(); expected.display_name = display_name.to_string(); expected.priority = priority; @@ -443,7 +458,6 @@ mod tests { expected.availability_nux = None; expected.upgrade = None; expected.use_responses_lite = false; - expected.tool_mode = None; expected.additional_speed_tiers.clear(); expected.service_tiers = if matches!( slug, diff --git a/codex-rs/model-provider/src/amazon_bedrock/mod.rs b/codex-rs/model-provider/src/amazon_bedrock/mod.rs index aceb7056f2..05d7eec7dc 100644 --- a/codex-rs/model-provider/src/amazon_bedrock/mod.rs +++ b/codex-rs/model-provider/src/amazon_bedrock/mod.rs @@ -714,6 +714,30 @@ mod tests { ); } + #[test] + fn govcloud_mantle_keeps_its_existing_tool_and_responses_modes() { + let mut info = ModelProviderInfo::create_amazon_bedrock_provider(/*aws*/ None); + info.base_url = Some("https://bedrock-mantle.us-gov-west-1.api.aws/openai/v1".to_string()); + let provider = AmazonBedrockModelProvider::new(info, /*auth_manager*/ None); + let catalog = provider.default_model_catalog(); + + assert_eq!( + catalog + .models + .iter() + .map(|model| ( + model.slug.as_str(), + model.tool_mode, + model.use_responses_lite, + )) + .collect::>(), + vec![ + ("openai.gpt-5.6-terra", None, false), + ("openai.gpt-5.6-luna", None, false), + ], + ); + } + #[test] fn capabilities_enable_web_search_but_disable_image_generation() { let provider = AmazonBedrockModelProvider::new( diff --git a/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog.rs b/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog.rs index f9020c63b1..a5113d4abc 100644 --- a/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog.rs +++ b/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog.rs @@ -44,7 +44,6 @@ pub(super) fn static_runtime_model_catalog() -> ModelsResponse { variant.slug = format!("{prefix}{}", model.slug); variant.display_name = format!("{} ({routing_label})", model.display_name); variant.priority = routing_priority * base_models.len() as i32 + model.priority; - variant.supports_search_tool = false; models.push(variant); } } diff --git a/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog_tests.rs b/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog_tests.rs index 81f7ebe5b0..5f4bfb819b 100644 --- a/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog_tests.rs +++ b/codex-rs/model-provider/src/amazon_bedrock/runtime_catalog_tests.rs @@ -1,6 +1,6 @@ -use codex_protocol::protocol::MultiAgentVersion; use pretty_assertions::assert_eq; +use super::static_model_catalog; use super::static_runtime_model_catalog; #[test] @@ -59,141 +59,32 @@ fn runtime_catalog_includes_supported_cross_region_models_in_priority_order() { } #[test] -fn runtime_catalog_disables_web_search_without_overriding_review_models() { - let catalog = static_runtime_model_catalog(); - - assert_eq!( - catalog +fn runtime_profiles_inherit_model_capabilities() { + let base = static_model_catalog(); + for profile in static_runtime_model_catalog().models { + let (_, slug) = profile.slug.split_once('.').expect("routing prefix"); + let model = base .models .iter() - .map(|model| ( - model.slug.as_str(), - model.auto_review_model_override.as_deref(), + .find(|model| model.slug == slug) + .expect("base model"); + assert_eq!( + ( + profile.supports_search_tool, + profile.multi_agent_version, + profile.auto_review_model_override, + profile.tool_mode, + profile.use_responses_lite, + ), + ( model.supports_search_tool, model.multi_agent_version, - )) - .collect::>(), - vec![ - ( - "global.openai.gpt-6.2-sol", None, - false, - Some(MultiAgentVersion::V2), + model.tool_mode, + model.use_responses_lite, ), - ( - "global.openai.gpt-6.2-astra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-6.1-terra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-6.1-sol", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-6-astra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-6-sol", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-6-luna", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-5.6-sol", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-5.6-terra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "global.openai.gpt-5.6-luna", - None, - false, - Some(MultiAgentVersion::V1), - ), - ( - "us.openai.gpt-6.2-sol", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-6.2-astra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-6.1-terra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-6.1-sol", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-6-astra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-6-sol", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-6-luna", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-5.6-sol", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-5.6-terra", - None, - false, - Some(MultiAgentVersion::V2), - ), - ( - "us.openai.gpt-5.6-luna", - None, - false, - Some(MultiAgentVersion::V1), - ), - ] - ); + "{}", + profile.slug + ); + } }