From ba8b40354160fa078cf36e24bb696d34100d8b1f Mon Sep 17 00:00:00 2001 From: Alex Kira Date: Sat, 7 Nov 2026 02:21:22 +0000 Subject: [PATCH] Restrict legacy incremental tools to Amazon Bedrock providers (#60040) ## What changed Gate `incremental_tools_legacy` on the `amazon-bedrock` and `amazon-bedrock-runtime` provider IDs instead of the OpenAI provider for regular Responses requests. Responses Lite continues to use `incremental_tools`. ## Testing Expand the tool catalog update scenarios to cover both Bedrock provider IDs with legacy incremental tools enabled and disabled. Update the regular Responses tool removal scenario to use the Bedrock provider. GitOrigin-RevId: ad0ff31975166a2a7fdcee6fefc272ecc79dd448 (cherry picked from commit 762f87d5bb8794bd4859cdd04061eb07c6c8bb8b) --- codex-rs/core/src/session/step_context.rs | 10 +++++++--- .../suite/scenarios_incremental_tools.rs | 19 +++++++++++++++---- codex-rs/features/src/lib.rs | 2 +- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/codex-rs/core/src/session/step_context.rs b/codex-rs/core/src/session/step_context.rs index e81733deef..62d534e87e 100644 --- a/codex-rs/core/src/session/step_context.rs +++ b/codex-rs/core/src/session/step_context.rs @@ -14,7 +14,8 @@ use codex_extension_api::ExtensionData; use codex_features::Feature; use codex_file_system::EnvironmentAccess; use codex_mcp::McpBinding; -use codex_model_provider_info::OPENAI_PROVIDER_ID; +use codex_model_provider_info::AMAZON_BEDROCK_PROVIDER_ID; +use codex_model_provider_info::AMAZON_BEDROCK_RUNTIME_PROVIDER_ID; use codex_otel::SessionTelemetry; use codex_plugin::ExecutorPluginHookSource; use codex_protocol::items::ModelInvocationContext; @@ -58,8 +59,11 @@ impl StepContext { if self.settings.model_info.use_responses_lite { Some(Feature::IncrementalTools) } else { - (self.turn.config.model_provider_id == OPENAI_PROVIDER_ID) - .then_some(Feature::IncrementalToolsLegacy) + matches!( + self.turn.config.model_provider_id.as_str(), + AMAZON_BEDROCK_PROVIDER_ID | AMAZON_BEDROCK_RUNTIME_PROVIDER_ID + ) + .then_some(Feature::IncrementalToolsLegacy) } } diff --git a/codex-rs/core/tests/suite/scenarios_incremental_tools.rs b/codex-rs/core/tests/suite/scenarios_incremental_tools.rs index c0c47c61e0..5f2b57b959 100644 --- a/codex-rs/core/tests/suite/scenarios_incremental_tools.rs +++ b/codex-rs/core/tests/suite/scenarios_incremental_tools.rs @@ -5,6 +5,9 @@ use codex_core::ForkSnapshot; use codex_core::McpServersDisabled; use codex_core::compact::AutoCompactionDisabled; use codex_features::Feature; +use codex_model_provider_info::AMAZON_BEDROCK_PROVIDER_ID; +use codex_model_provider_info::AMAZON_BEDROCK_RUNTIME_PROVIDER_ID; +use codex_model_provider_info::OPENAI_PROVIDER_ID; use codex_otel::MetricsClient; use codex_otel::MetricsConfig; use codex_otel::TOOL_INCREMENTAL_UPDATES_METRIC; @@ -148,15 +151,19 @@ async fn prediction_fork_keeps_inherited_tools() -> Result<()> { Ok(()) } -#[test_case(true, None, true; "responses_lite")] -#[test_case(true, Some(true), true; "announcements_suppressed")] -#[test_case(false, None, false; "responses_api")] -#[test_case(false, None, true; "responses_api_incremental")] +#[test_case(true, None, true, OPENAI_PROVIDER_ID; "responses_lite")] +#[test_case(true, Some(true), true, OPENAI_PROVIDER_ID; "announcements_suppressed")] +#[test_case(false, None, false, OPENAI_PROVIDER_ID; "responses_api")] +#[test_case(false, None, false, AMAZON_BEDROCK_PROVIDER_ID; "mantle_provider_id")] +#[test_case(false, None, true, AMAZON_BEDROCK_PROVIDER_ID; "mantle_provider_id_incremental")] +#[test_case(false, None, false, AMAZON_BEDROCK_RUNTIME_PROVIDER_ID; "runtime_provider_id")] +#[test_case(false, None, true, AMAZON_BEDROCK_RUNTIME_PROVIDER_ID; "runtime_provider_id_incremental")] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn incremental_tools_append_changed_catalog_without_rewriting_history( use_responses_lite: bool, suppress_model_change_announcements: Option, incremental_tools: bool, + provider_id: &'static str, ) -> Result<()> { skip_if_no_network!(Ok(())); let server = responses::start_mock_server().await; @@ -203,6 +210,7 @@ async fn incremental_tools_append_changed_catalog_without_rewriting_history( } }) .with_config(move |config| { + config.model_provider_id = provider_id.to_string(); if !use_responses_lite && incremental_tools { config .features @@ -504,6 +512,9 @@ async fn tool_removal_appends_a_standalone_notice_without_rewriting_history( } }) .with_config(move |config| { + if !use_responses_lite { + config.model_provider_id = AMAZON_BEDROCK_PROVIDER_ID.to_string(); + } config .features .enable(if use_responses_lite { diff --git a/codex-rs/features/src/lib.rs b/codex-rs/features/src/lib.rs index bc5c9824d3..2a981047c7 100644 --- a/codex-rs/features/src/lib.rs +++ b/codex-rs/features/src/lib.rs @@ -295,7 +295,7 @@ pub enum Feature { DeferredToolWorldState, /// Track top-level tool definitions in world state and emit incremental context updates. IncrementalTools, - /// Publish incremental tool declarations on regular OpenAI Responses. + /// Publish incremental tool declarations on regular Amazon Bedrock Responses. IncrementalToolsLegacy, /// Suppress the model ID announcement in incremental context after a model switch. SuppressModelChangeAnnouncements,