From 345f166d01fda88e6e723afbbfdce2efde843f74 Mon Sep 17 00:00:00 2001 From: Dylan Hurd Date: Wed, 18 Nov 2026 01:59:20 +0000 Subject: [PATCH] Wait for the search connector in hosted web search tests (#62165) ## Why MCP tool catalogs can change during startup, so a search binding captured during startup may go uncached. That makes the test's per-turn discovery request count depend on startup timing. ## What changed When hosted search is allowed, wait for the thread's connector to report `ready` before starting the first turn. This lets the test check discovery reuse with a stable binding. GitOrigin-RevId: 50d77eca6bfa7a6bfd5657e4c1ed3aad52beb8c5 --- codex-rs/app-server/tests/suite/v2/web_search.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/codex-rs/app-server/tests/suite/v2/web_search.rs b/codex-rs/app-server/tests/suite/v2/web_search.rs index 0eb5e0f1c0..85efad439d 100644 --- a/codex-rs/app-server/tests/suite/v2/web_search.rs +++ b/codex-rs/app-server/tests/suite/v2/web_search.rs @@ -890,6 +890,22 @@ async fn model_lab_search_provider( .build_initialized() .await?; let thread = app.start_thread(ThreadStartParams::default()).await?.thread; + if allow_hosted { + // A binding captured during MCP startup need not be cached: its catalogs can + // still change. Measure per-turn discovery reuse with an already stable binding. + timeout( + DEFAULT_READ_TIMEOUT, + app.read_stream_until_matching_notification("search connector ready", |notification| { + notification.method == "mcpServer/startupStatus/updated" + && notification.params.as_ref().is_some_and(|params| { + params["threadId"] == thread.id + && params["name"] == codex_mcp::CODEX_APPS_MCP_SERVER_NAME + && params["status"] == "ready" + }) + }), + ) + .await??; + } app.start_turn_and_wait_for_completion(TurnStartParams { thread_id: thread.id, responsesapi_client_metadata: match policy {