From 7edf91b13c54f20aab22fece0abfa4a5c28379b3 Mon Sep 17 00:00:00 2001 From: Winston Howes Date: Sat, 21 Nov 2026 01:17:09 +0000 Subject: [PATCH] Track explicit web search modes and expose indexed in the SDK (#62884) ## What changed Record whether an explicit `web_search` setting matches the effective mode after applying configuration requirements. Mark the thread manager sample's disabled mode as explicit. Accept `indexed` in the TypeScript SDK's `WebSearchMode` type. ## Testing Extend the SDK test to verify that both `cached` and `indexed` are passed to `codex exec` as `web_search` config overrides. GitOrigin-RevId: 0cf98c9a32f4da31fecc50da71acb601f6043b47 --- codex-rs/core/src/config/mod.rs | 7 +++++++ codex-rs/thread-manager-sample/src/main.rs | 1 + sdk/typescript/src/threadOptions.ts | 2 +- sdk/typescript/tests/run.test.ts | 8 ++++---- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs index 79683927fc..7438236290 100644 --- a/codex-rs/core/src/config/mod.rs +++ b/codex-rs/core/src/config/mod.rs @@ -1176,6 +1176,10 @@ pub struct Config { /// Explicit or feature-derived web search mode. pub web_search_mode: Constrained, + /// Whether this mode came from an accepted explicit `web_search` setting. + /// Kept with the session-static mode when user config layers are refreshed. + pub web_search_mode_was_explicit: bool, + /// Additional parameters for the web search tool when it is enabled. pub web_search_config: Option, @@ -4659,6 +4663,8 @@ impl Config { &mut constrained_web_search_mode, &mut startup_warnings, )?; + let web_search_mode_was_explicit = + cfg.web_search == Some(constrained_web_search_mode.value()); let mcp_servers = constrain_mcp_servers(cfg.mcp_servers.clone(), mcp_servers.as_ref()) .map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidInput, format!("{e}")))?; @@ -4987,6 +4993,7 @@ impl Config { forced_chatgpt_workspace_id, forced_login_method, web_search_mode: constrained_web_search_mode.value, + web_search_mode_was_explicit, web_search_config, experimental_request_user_input_enabled, update_plan_enabled, diff --git a/codex-rs/thread-manager-sample/src/main.rs b/codex-rs/thread-manager-sample/src/main.rs index 050a187e7f..eb92e73572 100644 --- a/codex-rs/thread-manager-sample/src/main.rs +++ b/codex-rs/thread-manager-sample/src/main.rs @@ -393,6 +393,7 @@ async fn new_config( forced_chatgpt_workspace_id: auth_config.forced_chatgpt_workspace_id.clone(), forced_login_method: auth_config.forced_login_method, web_search_mode: Constrained::allow_any(WebSearchMode::Disabled), + web_search_mode_was_explicit: true, web_search_config: None, experimental_request_user_input_enabled: true, update_plan_enabled: true, diff --git a/sdk/typescript/src/threadOptions.ts b/sdk/typescript/src/threadOptions.ts index 13cf0c5248..8f35c534a8 100644 --- a/sdk/typescript/src/threadOptions.ts +++ b/sdk/typescript/src/threadOptions.ts @@ -12,7 +12,7 @@ export type ModelReasoningEffort = | "ultra" | "persistent"; -export type WebSearchMode = "disabled" | "cached" | "live"; +export type WebSearchMode = "disabled" | "cached" | "indexed" | "live"; export type ThreadOptions = { model?: string; diff --git a/sdk/typescript/tests/run.test.ts b/sdk/typescript/tests/run.test.ts index 34a2742d1d..cbee0cfa7f 100644 --- a/sdk/typescript/tests/run.test.ts +++ b/sdk/typescript/tests/run.test.ts @@ -367,13 +367,13 @@ describe("Codex", () => { } }); - it("passes webSearchMode to exec", async () => { + it.each(["cached", "indexed"] as const)("passes %s webSearchMode to exec", async (mode) => { const { url, close } = await startResponsesTestProxy({ statusCode: 200, responseBodies: [ sse( responseStarted("response_1"), - assistantMessage("Web search cached", "item_1"), + assistantMessage(`Web search ${mode}`, "item_1"), responseCompleted("response_1"), ), ], @@ -384,13 +384,13 @@ describe("Codex", () => { try { const thread = client.startThread({ - webSearchMode: "cached", + webSearchMode: mode, }); await thread.run("test web search mode"); const commandArgs = spawnArgs[0]; expect(commandArgs).toBeDefined(); - expectPair(commandArgs, ["--config", 'web_search="cached"']); + expectPair(commandArgs, ["--config", `web_search="${mode}"`]); } finally { cleanup(); restore();