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
This commit is contained in:
Dylan Hurd
2026-11-18 02:31:46 +00:00
committed by copyberry
parent bb6b4b63b9
commit 345f166d01
@@ -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 {