From 378f1cabe828406d6f71c0e514775b2c01b661fe Mon Sep 17 00:00:00 2001 From: sayan-oai Date: Thu, 5 Feb 2026 14:57:07 -0800 Subject: [PATCH] go back to auto-enabling web_search for azure (#10820) ###### What Remove special-casing that prevented auto-enabling `web_search` for Azure model provider users. Addresses #10071, #10257. ###### Why Azure fixed their responsesapi implementation; `web_search` is now supported on models it wasn't before (like `gpt-5.1-codex-max`). This request now works: ``` curl "$AZURE_API_ENDPOINT" -H "Content-Type: application/json" -H "Authorization: Bearer $AZURE_API_KEY" -d '{ "model": "gpt-5.1-codex-max", "tools": [ { "type": "web_search" } ], "tool_choice": "auto", "input": "Find the sunrise time in Paris today and cite the source." }' ``` ###### Tests Tested with above curl, removed Azure-specific tests. --- codex-rs/core/src/codex.rs | 1 - codex-rs/core/src/config/mod.rs | 16 +------ codex-rs/core/src/model_provider_info.rs | 5 --- codex-rs/core/tests/suite/web_search.rs | 56 ------------------------ 4 files changed, 2 insertions(+), 76 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index b4c211883..326c54d5b 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -719,7 +719,6 @@ impl Session { per_turn_config.personality = session_configuration.personality; per_turn_config.web_search_mode = Some(resolve_web_search_mode_for_turn( per_turn_config.web_search_mode, - session_configuration.provider.is_azure_responses_endpoint(), session_configuration.sandbox_policy.get(), )); per_turn_config.features = config.features.clone(); diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs index 78f947db6..d9ddc5944 100644 --- a/codex-rs/core/src/config/mod.rs +++ b/codex-rs/core/src/config/mod.rs @@ -1288,15 +1288,11 @@ fn resolve_web_search_mode( pub(crate) fn resolve_web_search_mode_for_turn( explicit_mode: Option, - is_azure_responses_endpoint: bool, sandbox_policy: &SandboxPolicy, ) -> WebSearchMode { if let Some(mode) = explicit_mode { return mode; } - if is_azure_responses_endpoint { - return WebSearchMode::Disabled; - } if matches!(sandbox_policy, SandboxPolicy::DangerFullAccess) { WebSearchMode::Live } else { @@ -2413,14 +2409,14 @@ trust_level = "trusted" #[test] fn web_search_mode_for_turn_defaults_to_cached_when_unset() { - let mode = resolve_web_search_mode_for_turn(None, false, &SandboxPolicy::ReadOnly); + let mode = resolve_web_search_mode_for_turn(None, &SandboxPolicy::ReadOnly); assert_eq!(mode, WebSearchMode::Cached); } #[test] fn web_search_mode_for_turn_defaults_to_live_for_danger_full_access() { - let mode = resolve_web_search_mode_for_turn(None, false, &SandboxPolicy::DangerFullAccess); + let mode = resolve_web_search_mode_for_turn(None, &SandboxPolicy::DangerFullAccess); assert_eq!(mode, WebSearchMode::Live); } @@ -2429,20 +2425,12 @@ trust_level = "trusted" fn web_search_mode_for_turn_prefers_explicit_value() { let mode = resolve_web_search_mode_for_turn( Some(WebSearchMode::Cached), - false, &SandboxPolicy::DangerFullAccess, ); assert_eq!(mode, WebSearchMode::Cached); } - #[test] - fn web_search_mode_for_turn_disables_for_azure_responses_endpoint() { - let mode = resolve_web_search_mode_for_turn(None, true, &SandboxPolicy::DangerFullAccess); - - assert_eq!(mode, WebSearchMode::Disabled); - } - #[test] fn profile_legacy_toggles_override_base() -> std::io::Result<()> { let codex_home = TempDir::new()?; diff --git a/codex-rs/core/src/model_provider_info.rs b/codex-rs/core/src/model_provider_info.rs index 211822f48..305233ae7 100644 --- a/codex-rs/core/src/model_provider_info.rs +++ b/codex-rs/core/src/model_provider_info.rs @@ -8,7 +8,6 @@ use crate::auth::AuthMode; use crate::error::EnvVarError; use codex_api::Provider as ApiProvider; -use codex_api::is_azure_responses_wire_base_url; use codex_api::provider::RetryConfig as ApiRetryConfig; use http::HeaderMap; use http::header::HeaderName; @@ -174,10 +173,6 @@ impl ModelProviderInfo { }) } - pub(crate) fn is_azure_responses_endpoint(&self) -> bool { - is_azure_responses_wire_base_url(&self.name, self.base_url.as_deref()) - } - /// If `env_key` is Some, returns the API key for this provider if present /// (and non-empty) in the environment. If `env_key` is required but /// cannot be found, returns an error. diff --git a/codex-rs/core/tests/suite/web_search.rs b/codex-rs/core/tests/suite/web_search.rs index 8b1cc2a4e..edcbfd35d 100644 --- a/codex-rs/core/tests/suite/web_search.rs +++ b/codex-rs/core/tests/suite/web_search.rs @@ -1,7 +1,5 @@ #![allow(clippy::unwrap_used)] -use codex_core::WireApi; -use codex_core::built_in_model_providers; use codex_core::features::Feature; use codex_core::protocol::SandboxPolicy; use codex_protocol::config_types::WebSearchMode; @@ -22,15 +20,6 @@ fn find_web_search_tool(body: &Value) -> &Value { .expect("tools should include a web_search tool") } -#[allow(clippy::expect_used)] -fn has_web_search_tool(body: &Value) -> bool { - body["tools"] - .as_array() - .expect("request body should include tools array") - .iter() - .any(|tool| tool.get("type").and_then(Value::as_str) == Some("web_search")) -} - #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn web_search_mode_cached_sets_external_web_access_false() { skip_if_no_network!(); @@ -198,48 +187,3 @@ async fn web_search_mode_updates_between_turns_with_sandbox_policy() { "danger-full-access policy should default web_search to live" ); } - -#[tokio::test(flavor = "multi_thread", worker_threads = 2)] -async fn web_search_mode_defaults_to_disabled_for_azure_responses() { - skip_if_no_network!(); - - let server = start_mock_server().await; - let sse = responses::sse(vec![ - responses::ev_response_created("resp-1"), - responses::ev_completed("resp-1"), - ]); - let resp_mock = responses::mount_sse_once(&server, sse).await; - - let mut builder = test_codex() - .with_model("gpt-5-codex") - .with_config(|config| { - let base_url = config.model_provider.base_url.clone(); - let mut provider = built_in_model_providers()["openai"].clone(); - provider.name = "Azure".to_string(); - provider.base_url = base_url; - provider.wire_api = WireApi::Responses; - config.model_provider_id = provider.name.clone(); - config.model_provider = provider; - config.web_search_mode = None; - config.features.disable(Feature::WebSearchCached); - config.features.disable(Feature::WebSearchRequest); - }); - let test = builder - .build(&server) - .await - .expect("create test Codex conversation"); - - test.submit_turn_with_policy( - "hello azure default web search", - SandboxPolicy::DangerFullAccess, - ) - .await - .expect("submit turn"); - - let body = resp_mock.single_request().body_json(); - assert_eq!( - has_web_search_tool(&body), - false, - "azure responses requests should disable web_search by default" - ); -}