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
This commit is contained in:
Winston Howes
2026-11-21 01:40:15 +00:00
committed by copyberry
parent 619d36f810
commit 7edf91b13c
4 changed files with 13 additions and 5 deletions
+7
View File
@@ -1176,6 +1176,10 @@ pub struct Config {
/// Explicit or feature-derived web search mode.
pub web_search_mode: Constrained<WebSearchMode>,
/// 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<WebSearchConfig>,
@@ -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,
@@ -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,
+1 -1
View File
@@ -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;
+4 -4
View File
@@ -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();