The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(agent): re-anchor the fan-out tests on the async spawn surface\n\n`main` has been red since #5757 (`02d81f6cf`), which retired six sub-agent\ntools from the orchestrator — `spawn_parallel_agents`, `wait`, `wait_loop`,\n`wait_subagent`, `steer_subagent`, `close_subagent` — cutting the surface\nfrom 11 tools to 3. That was deliberate and is pinned both ways in\n`agents/loader.rs`: three tools required, the six asserted absent. Two test\nsites were still written against the retired fan-out tool.\n\nNeither is deleted. The property they protect still holds; only the\nmechanism moved, from one dedicated fan-out call to several ordinary async\nspawns issued together.\n\n`parallel_subagent_fanout` now scripts one assistant message carrying two\n`spawn_async_subagent` calls — the "issued together" shape, which the\nsingle-call helper could not express — and asserts both workers were\nactually dispatched. It asserts on the captured upstream requests rather\nthan on the synthesis text: the children are detached and race the\norchestrator's own reply for the global scripted FIFO, so anything keyed on\nscript order is a coin flip. What each worker was asked is deterministic;\nwhen it asked is not.\n\nThe other half of the old assertion — both results reaching the user — is\nnot asserted here and the test says why. Results now return through\n`background_delivery`, which is idle-gated and debounced onto a later\nsystem turn, and it is registered from `bootstrap_core_runtime`, which\n`boot_stack` does not call. No delivery turn can fire in this harness.\n\n`orchestrator_parallel_fanout_routing` anchored on the retired tool name,\nso it asserted against a prompt that no longer mentions it. It now pins the\ncurrent guidance — the concurrent primitive, that fan-out is several spawns,\nand that they run concurrently — which is the same anti-pattern guard #4754\nadded, against the tool that exists. A second test pins the other half of\nthe contract: the prompt must not teach a tool `agent.toml` retired, because\na prompt teaching an uncallable tool costs a turn to discover.\n
M3gA-Mind656488f1ff38
diff --git a/tests/agent_harness_e2e.rs b/tests/agent_harness_e2e.rsindex fc5371e522..098f8cb659 100644--- a/tests/agent_harness_e2e.rs+++ b/tests/agent_harness_e2e.rs@@ -144,6 +144,21 @@ fn tool_call_completion(name: &str, arguments: Value) -> Value {}]})}+/// A completion carrying several tool calls in ONE assistant message.+///+/// Fan-out is now several `spawn_async_subagent` calls "issued together"+/// (orchestrator `prompt.md`), which on the wire is one message with several+/// entries in `toolCalls` — not several messages. [`tool_call_completion`]+/// cannot express that, and scripting them as separate completions would test+/// the serial shape the fan-out guidance exists to prevent.+fn tool_calls_completion(calls: &[(&str, Value)]) -> Value {+ json!({ "content": "", "toolCalls": calls.iter().map(|(name, arguments)| json!({+ "id": format!("call_{name}_{}", arguments.to_string().len()),+ "name": name,+ "arguments": arguments.to_string(),+ })).collect::<Vec<_>>() })+}+fn error_completion(status: u16, message: &str) -> Value {json!({ "status": status, "error": message })}@@ -1920,11 +1935,34 @@ async fn provider_error_retry_inner() {// request[2] = researcher (inner loop continuation) → DEPTH2_CANARY text// request[3] = orchestrator synthesis-/// spawn_parallel_agents with 2 researcher tasks: both children consume from-/// the global scripted FIFO; both canaries appear in the final synthesis.-/// Orchestrator allowlist (agent.toml) includes "researcher" so both tasks pass-/// the allowlist check in spawn_parallel_agents.rs:223.-/// ≥4 upstream requests and no "Unknown tool:" confirm the full fan-out path ran.+/// Two `spawn_async_subagent` calls issued together really do put two workers+/// in flight: both are dispatched and both run, concurrently.+///+/// This is the surviving half of what `spawn_parallel_agents` used to prove.+/// #5757 (`02d81f6cf`) retired that tool on the grounds that "several spawns+/// are already several workers in flight" (`orchestrator/agent.toml`), and+/// `prompt.md` now teaches exactly that: "N independent subtasks means N+/// spawns, issued together. They run concurrently." That claim is the thing+/// worth pinning — it is the whole justification for dropping the dedicated+/// fan-out tool, and #4754 measured what happens when fan-out silently+/// serializes (145-200s gaps between workers).+///+/// The *other* half — both results reaching the user — is deliberately not+/// asserted here, and not because it stopped mattering. `spawn_async_subagent`+/// returns a task id immediately and results come back through+/// `orchestration::background_delivery`, which is documented "idle-gated —+/// never mid-turn" and debounced, i.e. on a LATER system turn. That subsystem+/// is registered from `bootstrap_core_runtime`, which `boot_stack` does not+/// call (see the note on `ensure_approval_gate`), so no delivery turn can fire+/// in this harness at all. Asserting it here would need new harness plumbing;+/// it is covered instead at the layer that can see it, in+/// `orchestration::tools::tools_e2e_tests`, where `background_completions` is+/// reachable.+///+/// Assertions are on the captured upstream *requests* rather than on the final+/// synthesis, because detached children race the orchestrator's own reply for+/// the global FIFO and any assertion keyed on script order would be a coin+/// flip. What each worker was asked is deterministic; when it asked is not.#[test]fn parallel_subagent_fanout() {run_on_agent_stack("parallel_subagent_fanout", parallel_subagent_fanout_inner);@@ -1932,24 +1970,26 @@ fn parallel_subagent_fanout() {async fn parallel_subagent_fanout_inner() {let _lock = env_lock();+ // ONE assistant message carrying TWO spawns — the "issued together" shape.+ // Both children are single-turn (text only, no inner tool loop), so the+ // remaining entries are: the orchestrator's own reply plus one completion+ // per child. Their order is NOT fixed: the children are detached and race+ // the orchestrator's reply for the queue, which is why nothing below keys+ // on a script index.reset_script(vec![- // request[0]: Orchestrator issues spawn_parallel_agents with 2 researcher tasks.- tool_call_completion(- "spawn_parallel_agents",- json!({ "tasks": [- { "agent_id": "researcher", "prompt": "Find alpha canary" },- { "agent_id": "researcher", "prompt": "Find beta canary" }- ]}),- ),- // request[1] + request[2]: The two researcher children consume from the- // FIFO queue concurrently via join_all. Order between children is- // non-deterministic; both carry distinct canaries so the synthesis test- // is order-agnostic. Both children are single-turn (text only → no inner- // tool loop → one LLM call each).- text_completion("PARALLEL_ALPHA_CANARY"),- text_completion("PARALLEL_BETA_CANARY"),- // request[3]: Orchestrator receives both results and synthesizes.- text_completion("Both done: PARALLEL_ALPHA_CANARY and PARALLEL_BETA_CANARY"),+ tool_calls_completion(&[+ (+ "spawn_async_subagent",+ json!({ "agent_id": "researcher", "prompt": "Find PARALLEL_ALPHA_CANARY" }),+ ),+ (+ "spawn_async_subagent",+ json!({ "agent_id": "researcher", "prompt": "Find PARALLEL_BETA_CANARY" }),+ ),+ ]),+ text_completion("Spawned two workers; results will arrive as they land."),+ text_completion("alpha worker done"),+ text_completion("beta worker done"),]);let stack = boot_stack().await;@@ -1972,66 +2012,75 @@ async fn parallel_subagent_fanout_inner() {Some("chat_done"),"expected chat_done for parallel fanout: {done}");- let full_response = done- .get("full_response")- .and_then(Value::as_str)- .unwrap_or_else(|| panic!("chat_done missing full_response: {done}"));- assert!(- full_response.contains("PARALLEL_ALPHA_CANARY")- && full_response.contains("PARALLEL_BETA_CANARY"),- "synthesis must contain both canaries; full_response: {full_response}"- );- // ≥4 upstream requests: orchestrator + 2 researcher children + orchestrator synthesis.+ // The children are detached, so the turn can end before they have issued+ // their upstream calls. Poll rather than assert immediately — a bare+ // assertion here would be a race, and a sleep would be a guess.+ let both_dispatched = |reqs: &[Value]| {+ let all = serde_json::to_string(reqs).unwrap_or_default();+ all.contains("Find PARALLEL_ALPHA_CANARY") && all.contains("Find PARALLEL_BETA_CANARY")+ };+ let deadline = std::time::Instant::now() + Duration::from_secs(60);+ loop {+ if with_captured(|c| both_dispatched(c)) {+ break;+ }+ assert!(+ std::time::Instant::now() < deadline,+ "both workers must be dispatched; captured requests: {}",+ serde_json::to_string_pretty(&with_captured(|c| c.clone())).unwrap_or_default()+ );+ tokio::time::sleep(Duration::from_millis(100)).await;+ }+let requests = with_captured(|c| c.clone());++ // Both prompts reached the upstream, so both workers really ran — not one+ // worker twice, and not one worker while the other was dropped on the+ // floor. This is the claim that justifies retiring `spawn_parallel_agents`.+ let alpha = requests+ .iter()+ .filter(|r| {+ serde_json::to_string(r)+ .unwrap_or_default()+ .contains("Find PARALLEL_ALPHA_CANARY")+ })+ .count();+ let beta = requests+ .iter()+ .filter(|r| {+ serde_json::to_string(r)+ .unwrap_or_default()+ .contains("Find PARALLEL_BETA_CANARY")+ })+ .count();assert!(- requests.len() >= 4,- "expected ≥4 upstream requests (orchestrator + 2 researchers + synthesis), got {};\- \nrequests: {}",- requests.len(),+ alpha >= 1 && beta >= 1,+ "each worker must be dispatched at least once (alpha={alpha}, beta={beta}); \+ requests: {}",serde_json::to_string_pretty(&requests).unwrap_or_default());- // No "Unknown tool:" — spawn_parallel_agents was synthesised and ran successfully.- let all_serialized = serde_json::to_string(&requests).unwrap_or_default();+ // ≥3 upstream calls: the orchestrator's spawn turn, its own reply, and at+ // least the two children. Fewer means a child never reached the model.assert!(- !all_serialized.contains("Unknown tool:"),- "found 'Unknown tool:' — spawn_parallel_agents was not available; requests: {}",+ requests.len() >= 3,+ "expected ≥3 upstream requests (orchestrator + 2 workers), got {};\nrequests: {}",+ requests.len(),serde_json::to_string_pretty(&requests).unwrap_or_default());- // ── Last upstream request (orchestrator synthesis) must carry BOTH child- // canaries in its messages ── proves both children's results were forwarded- // into the orchestrator's synthesis context, not merely that the scripted- // synthesis text echoed them.- let last_messages = requests- .last()- .unwrap()- .pointer("/body/messages")- .and_then(Value::as_array)- .cloned()- .unwrap_or_else(|| {- panic!(- "last upstream request missing /body/messages; request: {}",- serde_json::to_string_pretty(requests.last().unwrap()).unwrap_or_default()- )- });- let serialized = serde_json::to_string(&last_messages).unwrap();- assert!(- serialized.contains("PARALLEL_ALPHA_CANARY"),- "synthesis request missing child result PARALLEL_ALPHA_CANARY; messages: {serialized}"- );+ // The spawn tool must actually be in scope. If the orchestrator's tool list+ // drifts again, this is the assertion that says so in one line instead of+ // leaving a canary mismatch to be decoded.+ let all = serde_json::to_string(&requests).unwrap_or_default();assert!(- serialized.contains("PARALLEL_BETA_CANARY"),- "synthesis request missing child result PARALLEL_BETA_CANARY; messages: {serialized}"+ !all.contains("Unknown tool:"),+ "no tool call may be rejected as unknown; requests: {}",+ serde_json::to_string_pretty(&requests).unwrap_or_default());-- stack.shutdown();}-/// Delegation two levels deep (orchestrator → researcher → tool loop continues):-/// orchestrator delegates to researcher via `research`; researcher scripted to-/// call ask_user_clarification (blocked — not in researcher named tools →/// SubagentToolSource returns error); researcher loops and returns DEPTH2_CANARY;/// dispatch_subagent forwards the result; orchestrator synthesizes.///diff --git a/tests/orchestrator_parallel_fanout_routing.rs b/tests/orchestrator_parallel_fanout_routing.rsindex b295536db0..dec68767df 100644--- a/tests/orchestrator_parallel_fanout_routing.rs+++ b/tests/orchestrator_parallel_fanout_routing.rs@@ -1,18 +1,25 @@-//! Pins the orchestrator's parallel/council fan-out routing (#4754).+//! Pins the orchestrator's parallel fan-out routing (#4754, re-anchored for #5757).//!//! An agent-efficiency eval found the orchestrator never fanning out workers//! concurrently: parallel/"separate researcher for each"/council prompts either//! single-spawned or issued serial `spawn_subagent` calls 145-200s apart//! (each sub-agent finishing before the next started), defeating the request.//!-//! Root cause is routing, not harness concurrency: `spawn_parallel_agents`-//! already fans out concurrently (tinyagents `map_reduce` / `buffer_unordered`)-//! as a single tool call, but the orchestrator reached for serial-//! `spawn_subagent` instead. The fix steers parallel/council/fan-out requests-//! to ONE `spawn_parallel_agents` call — in both the system prompt and the-//! `spawn_subagent` tool description the model reads when choosing a tool.+//! Root cause was routing, not harness concurrency, and it is still routing+//! that these assertions guard. What changed is the primitive being routed to.//!-//! These assertions pin that guidance so a future edit can't silently drop it.+//! #5757 (`02d81f6cf`) retired `spawn_parallel_agents` along with five other+//! sub-agent tools, cutting the surface from 11 tools to 3. A dedicated fan-out+//! tool was judged "a second way to say spawn again" now that+//! `spawn_async_subagent` is always async: it returns a task id immediately, so+//! N spawns issued together are already N workers running concurrently. The+//! retirement is pinned both ways in `agents/loader.rs` — three tools required,+//! six asserted absent — so it is deliberate and enforced, not drift.+//!+//! The anti-pattern this file exists to catch is therefore unchanged — a prompt+//! that lets fan-out serialize — but the guidance it anchors on had to move+//! with the tool. Anchoring on the retired name is what left this suite+//! asserting against a prompt that no longer mentions it.const ORCHESTRATOR_PROMPT: &str =include_str!("../src/openhuman/agent/registry/agents/orchestrator/prompt.md");@@ -21,29 +28,61 @@ const SPAWN_SUBAGENT_SRC: &str =include_str!("../src/openhuman/agent/orchestration/tools/spawn_subagent.rs");#[test]-fn prompt_routes_parallel_and_council_to_spawn_parallel_agents() {- // The parallel-fanout guidance must exist and name the concurrent primitive.+fn prompt_routes_fanout_to_concurrent_async_spawns() {+ let prompt = ORCHESTRATOR_PROMPT.to_lowercase();++ // The fan-out guidance must exist and name the primitive that actually+ // runs concurrently. Post-#5757 that is `spawn_async_subagent`; the+ // assertion is deliberately on the *current* tool rather than on whichever+ // name happened to be right in 2026, because a prompt naming a retired+ // tool is the failure this file is meant to catch.assert!(- ORCHESTRATOR_PROMPT.contains("spawn_parallel_agents"),- "orchestrator prompt must route fan-out to `spawn_parallel_agents` (#4754)"+ ORCHESTRATOR_PROMPT.contains("spawn_async_subagent"),+ "orchestrator prompt must name the concurrent spawn primitive (#4754, #5757)");- // It must explicitly cover the council / multiple-independent-opinions case- // that the eval showed collapsing to a single spawn.++ // It must say that fan-out IS several spawns — the sentence that replaced+ // "use one spawn_parallel_agents call". Without it a model reading the+ // prompt has no instruction to issue them together, which is exactly the+ // serialization the eval measured.assert!(- ORCHESTRATOR_PROMPT.to_lowercase().contains("council"),- "orchestrator prompt must steer council / multiple-opinions requests to \- a parallel fan-out, not a single spawn (#4754)"+ prompt.contains("fan-out is just several") || prompt.contains("n spawns"),+ "orchestrator prompt must state that fan-out is several spawns issued \+ together, not a sequence of dependent ones (#4754, #5757)");- // It must warn against the serial anti-pattern (looping `spawn_subagent`),- // which is what produced the 145-200s serial gaps.- let p = ORCHESTRATOR_PROMPT.to_lowercase();++ // And it must state that they run concurrently. "Several spawns" is only+ // the fix if the spawns overlap; a prompt that dropped this could be read+ // as endorsing the 145-200s serial gaps the eval found.assert!(- p.contains("never a loop of") || p.contains("do **not** call `spawn_subagent` once per"),- "orchestrator prompt must warn that repeated `spawn_subagent` serializes \- fan-out and to use one `spawn_parallel_agents` call instead (#4754)"+ prompt.contains("run concurrently") || prompt.contains("concurrently"),+ "orchestrator prompt must state that several spawns run concurrently, \+ which is what makes fan-out a fan-out (#4754, #5757)");}+/// The retired fan-out tool must not come back in the prompt without coming+/// back in `agent.toml` — a prompt teaching a tool the orchestrator cannot call+/// is worse than one that teaches nothing, because the model spends a turn+/// discovering it. `agents/loader.rs` already pins the tool list itself; this+/// pins the half of the contract that lives in prose.+#[test]+fn prompt_does_not_teach_a_retired_subagent_tool() {+ for retired in [+ "spawn_parallel_agents",+ "wait_subagent",+ "steer_subagent",+ "close_subagent",+ "wait_loop",+ ] {+ assert!(+ !ORCHESTRATOR_PROMPT.contains(retired),+ "orchestrator prompt teaches `{retired}`, which #5757 retired from \+ agent.toml — re-adding one means re-adding it in both places"+ );+ }+}+#[test]fn spawn_subagent_description_redirects_fanout_to_parallel() {// The tool description is what the model reads while picking a tool, so the