add WebSearchMode enum (#9216)

### What
Add `WebSearchMode` enum (disabled, cached live, defaults to cached) to
config + V2 protocol. This enum takes precedence over legacy flags:
`web_search_cached`, `web_search_request`, and `tools.web_search`.

Keep `--search` as live.

### Tests
Added tests
This commit is contained in:
sayan-oai
2026-01-14 12:51:42 -08:00
committed by GitHub
parent 27da8a68d3
commit 5e426ac270
22 changed files with 302 additions and 72 deletions

View File

@@ -1,5 +1,6 @@
#![allow(clippy::unwrap_used)]
use codex_protocol::config_types::WebSearchMode;
use core_test_support::load_sse_fixture_with_id;
use core_test_support::responses;
use core_test_support::responses::start_mock_server;
@@ -32,7 +33,10 @@ async fn collect_tool_identifiers_for_model(model: &str) -> Vec<String> {
let sse = sse_completed(model);
let resp_mock = responses::mount_sse_once(&server, sse).await;
let mut builder = test_codex().with_model(model);
let mut builder = test_codex()
.with_model(model)
// Keep tool expectations stable when the default web_search mode changes.
.with_config(|config| config.web_search_mode = WebSearchMode::Cached);
let test = builder
.build(&server)
.await
@@ -58,6 +62,7 @@ async fn model_selects_expected_tools() {
"list_mcp_resource_templates".to_string(),
"read_mcp_resource".to_string(),
"update_plan".to_string(),
"web_search".to_string(),
"view_image".to_string()
],
"codex-mini-latest should expose the local shell tool",
@@ -73,6 +78,7 @@ async fn model_selects_expected_tools() {
"read_mcp_resource".to_string(),
"update_plan".to_string(),
"apply_patch".to_string(),
"web_search".to_string(),
"view_image".to_string()
],
"gpt-5-codex should expose the apply_patch tool",
@@ -88,6 +94,7 @@ async fn model_selects_expected_tools() {
"read_mcp_resource".to_string(),
"update_plan".to_string(),
"apply_patch".to_string(),
"web_search".to_string(),
"view_image".to_string()
],
"gpt-5.1-codex should expose the apply_patch tool",
@@ -102,6 +109,7 @@ async fn model_selects_expected_tools() {
"list_mcp_resource_templates".to_string(),
"read_mcp_resource".to_string(),
"update_plan".to_string(),
"web_search".to_string(),
"view_image".to_string()
],
"gpt-5 should expose the apply_patch tool",
@@ -117,6 +125,7 @@ async fn model_selects_expected_tools() {
"read_mcp_resource".to_string(),
"update_plan".to_string(),
"apply_patch".to_string(),
"web_search".to_string(),
"view_image".to_string()
],
"gpt-5.1 should expose the apply_patch tool",
@@ -132,6 +141,7 @@ async fn model_selects_expected_tools() {
"read_mcp_resource".to_string(),
"update_plan".to_string(),
"apply_patch".to_string(),
"web_search".to_string(),
"view_image".to_string()
],
"exp-5.1 should expose the apply_patch tool",