Lightweight coding agent that runs in your terminal
Rust
Enable multi-agent V2 and Ultra reasoning on Amazon Bedrock (#49345)
Celia Chen8ffd91e42aa0
diff --git a/codex-rs/core/tests/suite/bedrock_multi_agent_tests.rs b/codex-rs/core/tests/suite/bedrock_multi_agent_tests.rsnew file mode 100644index 0000000000..ddc5ebf1cf--- /dev/null+++ b/codex-rs/core/tests/suite/bedrock_multi_agent_tests.rs@@ -0,0 +1,62 @@+//! Verifies default Bedrock catalogs select V2 and expose its collaboration tools.++use codex_features::Feature;+use codex_login::CodexAuth;+use codex_login::auth::BedrockApiKeyAuth;+use codex_model_provider_info::AMAZON_BEDROCK_PROVIDER_ID;+use codex_model_provider_info::AMAZON_BEDROCK_RUNTIME_PROVIDER_ID;+use codex_model_provider_info::built_in_model_providers;+use codex_protocol::protocol::MultiAgentVersion;+use core_test_support::responses;+use core_test_support::skip_if_no_network;+use core_test_support::test_codex::test_codex;+use pretty_assertions::assert_eq;++#[test_case::test_case(AMAZON_BEDROCK_PROVIDER_ID, "openai.gpt-5.6-sol"; "mantle")]+#[test_case::test_case(AMAZON_BEDROCK_RUNTIME_PROVIDER_ID, "global.openai.gpt-5.6-sol"; "runtime")]+#[tokio::test(flavor = "multi_thread", worker_threads = 2)]+async fn bedrock_catalog_selects_v2_by_default(+ provider_id: &'static str,+ model: &'static str,+) -> anyhow::Result<()> {+ skip_if_no_network!(Ok(()));+ let server = responses::start_mock_server().await;+ let mock = responses::mount_sse_once(+ &server,+ responses::sse(vec![responses::ev_completed("done")]),+ )+ .await;+ let test = test_codex()+ .with_auth(CodexAuth::BedrockApiKey(BedrockApiKeyAuth {+ api_key: "dummy".to_string(),+ region: "us-east-1".to_string(),+ }))+ .with_model(model)+ .with_config(move |config| {+ let base_url = config.model_provider.base_url.clone();+ config.model_provider_id = provider_id.to_string();+ config.model_provider = built_in_model_providers(/*openai_base_url*/ None)+ .remove(provider_id)+ .expect("built-in Bedrock provider");+ config.model_provider.base_url = base_url;+ })+ .build_with_auto_env(&server)+ .await?;+ assert!(!test.config.features.enabled(Feature::MultiAgentV2));+ assert!(test.config.model_catalog.is_none());++ test.submit_text_turn("Hello").await?;++ assert_eq!(+ test.codex.multi_agent_version(),+ Some(MultiAgentVersion::V2)+ );+ let request = mock.single_request();+ for tool in ["spawn_agent", "followup_task"] {+ assert!(+ request.tool_by_name("collaboration", tool).is_some(),+ "default Bedrock catalog should expose collaboration.{tool}",+ );+ }+ Ok(())+}diff --git a/codex-rs/core/tests/suite/mod.rs b/codex-rs/core/tests/suite/mod.rsindex 14805e25b5..1be4f9710f 100644--- a/codex-rs/core/tests/suite/mod.rs+++ b/codex-rs/core/tests/suite/mod.rs@@ -54,6 +54,8 @@ mod approvals;mod audio_truncation;mod auth_recovery_policy;mod auto_review;+#[path = "bedrock_multi_agent_tests.rs"]+mod bedrock_multi_agent;mod catalog_permission_messages;mod cli_stream;mod client;diff --git a/codex-rs/model-provider/src/amazon_bedrock/catalog.rs b/codex-rs/model-provider/src/amazon_bedrock/catalog.rsindex c7c478436b..1de3b24436 100644--- a/codex-rs/model-provider/src/amazon_bedrock/catalog.rs+++ b/codex-rs/model-provider/src/amazon_bedrock/catalog.rs@@ -10,9 +10,7 @@ use codex_models_manager::bundled_models_response;use codex_protocol::openai_models::ModelInfo;use codex_protocol::openai_models::ModelVisibility;use codex_protocol::openai_models::ModelsResponse;-use codex_protocol::openai_models::ReasoningEffort;use codex_protocol::openai_models::WebSearchToolType;-use codex_protocol::protocol::MultiAgentVersion;const GPT_5_BEDROCK_CONTEXT_WINDOW: i64 = 272_000;const GPT_5_6_SOL_OPENAI_MODEL_ID: &str = "gpt-5.6-sol";@@ -98,8 +96,6 @@ pub(crate) fn normalize_bedrock_catalog(mut catalog: ModelsResponse) -> ModelsRemodel.default_service_tier = None;// Bedrock rejects the `search_content_types` field used by multimodal search.model.web_search_tool_type = WebSearchToolType::Text;- // Bedrock does not support the response items used by multi-agent V2.- model.multi_agent_version = Some(MultiAgentVersion::V1);}catalog}@@ -137,9 +133,6 @@ fn bedrock_model(model.use_responses_lite = false;model.tool_mode = None;model- .supported_reasoning_levels- .retain(|level| level.effort != ReasoningEffort::Ultra);- model}fn bundled_openai_model(slug: &str) -> ModelInfo {@@ -154,6 +147,7 @@ fn bundled_openai_model(slug: &str) -> ModelInfo {#[cfg(test)]mod tests {use codex_protocol::config_types::SERVICE_TIER_DEFAULT_REQUEST_VALUE;+ use codex_protocol::protocol::MultiAgentVersion;use pretty_assertions::assert_eq;use super::*;@@ -251,21 +245,30 @@ mod tests {#[test]fn configured_bedrock_catalogs_normalize_unsupported_model_capabilities() {- let model = bundled_openai_model(GPT_5_5_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;- expected.multi_agent_version = Some(MultiAgentVersion::V1);+ let models = [+ Some(MultiAgentVersion::V2),+ Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::Disabled),+ None,+ ]+ .into_iter()+ .map(|version| {+ let mut model = bundled_openai_model(GPT_5_5_OPENAI_MODEL_ID);+ model.multi_agent_version = version;+ model+ })+ .collect::<Vec<_>>();+ let mut expected = models.clone();+ for model in &mut expected {+ model.additional_speed_tiers.clear();+ model.service_tiers.clear();+ model.default_service_tier = None;+ model.web_search_tool_type = WebSearchToolType::Text;+ }assert_eq!(- normalize_bedrock_catalog(ModelsResponse {- models: vec![model],- }),- ModelsResponse {- models: vec![expected],- }+ normalize_bedrock_catalog(ModelsResponse { models }),+ ModelsResponse { models: expected });}@@ -343,14 +346,10 @@ mod tests {expected.upgrade = None;expected.use_responses_lite = false;expected.tool_mode = None;- expected- .supported_reasoning_levels- .retain(|level| level.effort != ReasoningEffort::Ultra);expected.additional_speed_tiers.clear();expected.service_tiers.clear();expected.default_service_tier = None;expected.web_search_tool_type = WebSearchToolType::Text;- expected.multi_agent_version = Some(MultiAgentVersion::V1);assert_eq!(catalog.models.iter().find(|model| model.slug == slug),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.rsindex 9f6f6ad8b7..f769d03481 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@@ -64,13 +64,13 @@ fn runtime_catalog_disables_web_search_without_overriding_review_models() {"global.openai.gpt-6.1-sol",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("global.openai.gpt-6-astra",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("global.openai.gpt-6-sol",@@ -82,19 +82,19 @@ fn runtime_catalog_disables_web_search_without_overriding_review_models() {"global.openai.gpt-6-luna",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("global.openai.gpt-5.6-sol",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("global.openai.gpt-5.6-terra",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("global.openai.gpt-5.6-luna",@@ -106,13 +106,13 @@ fn runtime_catalog_disables_web_search_without_overriding_review_models() {"us.openai.gpt-6.1-sol",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("us.openai.gpt-6-astra",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("us.openai.gpt-6-sol",@@ -124,19 +124,19 @@ fn runtime_catalog_disables_web_search_without_overriding_review_models() {"us.openai.gpt-6-luna",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("us.openai.gpt-5.6-sol",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("us.openai.gpt-5.6-terra",None,false,- Some(MultiAgentVersion::V1),+ Some(MultiAgentVersion::V2),),("us.openai.gpt-5.6-luna",diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_astra_advanced_reasoning.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_astra_advanced_reasoning.snapnew file mode 100644index 0000000000..8518e8551c--- /dev/null+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_astra_advanced_reasoning.snap@@ -0,0 +1,12 @@+---+source: tui/src/chatwidget/tests/bedrock_catalog_tests.rs+expression: "render_bottom_popup(&chat, 100)"+---+ Advanced Reasoning+ ⚠ Consumes usage limits faster+++› 1. Max For difficult problems when quality matters more than speed · higher usage+ 2. Ultra For demanding work using multiple agents · highest usage++ enter default · s session · esc backdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_astra_reasoning.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_astra_reasoning.snapindex 5defe22380..07d5728a69 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_astra_reasoning.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_mantle_astra_reasoning.snap@@ -9,6 +9,6 @@ expression: "render_bottom_popup(&chat, 100)"2. Medium Balances speed and reasoning depth for everyday tasks3. High Greater reasoning depth for complex problems4. Extra high Extra high reasoning depth for complex problems- 5. More reasoning… Max consumes usage limits faster+ 5. More reasoning… Max and Ultra consume usage limits fasterenter default · s session · esc backdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_astra_advanced_reasoning.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_astra_advanced_reasoning.snapnew file mode 100644index 0000000000..8518e8551c--- /dev/null+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_astra_advanced_reasoning.snap@@ -0,0 +1,12 @@+---+source: tui/src/chatwidget/tests/bedrock_catalog_tests.rs+expression: "render_bottom_popup(&chat, 100)"+---+ Advanced Reasoning+ ⚠ Consumes usage limits faster+++› 1. Max For difficult problems when quality matters more than speed · higher usage+ 2. Ultra For demanding work using multiple agents · highest usage++ enter default · s session · esc backdiff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_astra_reasoning.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_astra_reasoning.snapindex f74507aa3c..d220a75654 100644--- a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_astra_reasoning.snap+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__bedrock_runtime_astra_reasoning.snap@@ -9,6 +9,6 @@ expression: "render_bottom_popup(&chat, 100)"2. Medium Balances speed and reasoning depth for everyday tasks3. High Greater reasoning depth for complex problems4. Extra high Extra high reasoning depth for complex problems- 5. More reasoning… Max consumes usage limits faster+ 5. More reasoning… Max and Ultra consume usage limits fasterenter default · s session · esc backdiff --git a/codex-rs/tui/src/chatwidget/tests/bedrock_catalog_tests.rs b/codex-rs/tui/src/chatwidget/tests/bedrock_catalog_tests.rsindex ca29f275dd..5f0cb91520 100644--- a/codex-rs/tui/src/chatwidget/tests/bedrock_catalog_tests.rs+++ b/codex-rs/tui/src/chatwidget/tests/bedrock_catalog_tests.rs@@ -42,7 +42,7 @@ async fn bedrock_astra_model_and_reasoning_pickers() {.find(|model| model.model == astra_model).expect("Astra preset").clone();- let (mut chat, _events, _ops) = make_chatwidget_manual(Some(default_model)).await;+ let (mut chat, mut events, _ops) = make_chatwidget_manual(Some(default_model)).await;chat.thread_id = Some(ThreadId::new());chat.model_catalog = Arc::new(ModelCatalog::new(presets));chat.open_model_popup();@@ -56,6 +56,35 @@ async fn bedrock_astra_model_and_reasoning_pickers() {format!("bedrock_{name}_astra_reasoning"),render_bottom_popup(&chat, /*width*/ 100));+ chat.handle_key_event(KeyEvent::from(KeyCode::Char('5')));+ let advanced =+ std::iter::from_fn(|| events.try_recv().ok()).find_map(|event| match event {+ AppEvent::OpenAdvancedReasoningPopup { model } => Some(model),+ _ => None,+ });+ chat.open_advanced_reasoning_popup(advanced.expect("advanced reasoning popup"));+ assert_chatwidget_snapshot!(+ format!("bedrock_{name}_astra_advanced_reasoning"),+ render_bottom_popup(&chat, /*width*/ 100)+ );+ chat.handle_key_event(KeyEvent::from(KeyCode::Char('2')));+ let selected =+ std::iter::from_fn(|| events.try_recv().ok()).find_map(|event| match event {+ AppEvent::AstraSelectedFromModelPicker {+ thread_id,+ model,+ action: AstraModelPickerAction::ApplyAdvancedReasoning { effort },+ } => Some((thread_id, model, effort)),+ _ => None,+ });+ assert_eq!(+ selected,+ Some((+ chat.thread_id.expect("active thread"),+ astra_model.to_string(),+ ReasoningEffortConfig::Ultra,+ ))+ );}}