From 265ccf1b65251ed56b2ed9b2e659abdcc6ef2b4e Mon Sep 17 00:00:00 2001 From: M3gA-Mind Date: Wed, 28 Oct 2026 11:30:09 +0530 Subject: [PATCH] test(flows): let the builder result's delivery turn end before the save A finished async sub-agent is delivered into the thread by a debounced turn. When it ran late it consumed the responses scripted for the save step. Wait for that turn's stored reply before scripting the save. --- tests/json_rpc_flows_builder_chat_e2e.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/json_rpc_flows_builder_chat_e2e.rs b/tests/json_rpc_flows_builder_chat_e2e.rs index 4cd4be8beb..b9a97fb725 100644 --- a/tests/json_rpc_flows_builder_chat_e2e.rs +++ b/tests/json_rpc_flows_builder_chat_e2e.rs @@ -580,6 +580,21 @@ async fn chat_spawns_workflow_builder_and_saves_its_proposal() { }) .await; + // The completion is then delivered by a debounced turn on the thread. Let + // it end, its reply stored, before step 4 scripts the orchestrator, or it + // takes the save's `spawn_subagent`. + wait_for("the builder result's delivery turn", || { + let rpc_base = rpc_base.clone(); + let thread_id = thread_id.clone(); + async move { + thread_messages(&rpc_base, &thread_id) + .await + .into_iter() + .find(|m| m["extraMetadata"]["scope"] == "background_delivery") + } + }) + .await; + // ── 4. the agent-side "save it": one flow, its schedule born disabled ── // The order a user takes: ask the agent to save, then press the card. assert_eq!(flow_count(&rpc_base).await, 0, "no flow before the save");