fix: dont auto-enable web_search for azure (#10266)

seeing issues with azure after default-enabling web search: #10071,
#10257.

need to work with azure to fix api-side, for now turning off
default-enable of web_search for azure.

diff is big because i moved logic to reuse
This commit is contained in:
sayan-oai
2026-01-30 14:52:37 -08:00
committed by GitHub
parent d59685f6d4
commit 31d1e49340
7 changed files with 148 additions and 98 deletions

View File

@@ -80,5 +80,5 @@ mod unstable_features_warning;
mod user_notification;
mod user_shell_cmd;
mod view_image;
mod web_search_cached;
mod web_search;
mod websocket_fallback;

View File

@@ -1,5 +1,7 @@
#![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;
@@ -25,6 +27,15 @@ 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!();
@@ -174,3 +185,45 @@ 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 = sse_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"
);
}