Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore(tests): add e2e test for agent harness

Steven Enamakelca9b863112a4
diff --git a/tests/agent_harness_e2e.rs b/tests/agent_harness_e2e.rs
index 6a34b0f3b2..c643ca1d86 100644
--- a/tests/agent_harness_e2e.rs
+++ b/tests/agent_harness_e2e.rs
@@ -705,9 +705,9 @@ impl Drop for Stack {
async fn boot_stack() -> Stack {
// Ensure the global AgentDefinitionRegistry is populated with built-in
- // archetypes (orchestrator, researcher, task_manager_agent, etc.) before
+ // archetypes (orchestrator, planner, task_manager_agent, etc.) before
// the RPC stack starts. Without this the session builder cannot synthesise
- // delegation tools and every `research`/`spawn_subagent` call becomes
+ // delegation tools and every `plan`/`spawn_subagent` call becomes
// "Unknown tool: …", making delegation tests vacuous.
init_agent_def_registry();
@@ -992,22 +992,22 @@ async fn multi_turn_state_persistence_inner() {
// ─── Task 3: Subagent delegation happy path ───────────────────────────────────
//
// Tool surface (crates/openhuman-core/src/tools/orchestrator_tools.rs,
-// crates/openhuman-core/src/agent/registry/agents/researcher/agent.toml):
-// - researcher has `delegate_name = "research"`, so the orchestrator LLM sees a
-// tool named "research" synthesised by collect_orchestrator_tools.
+// crates/openhuman-core/src/agent/registry/agents/planner/agent.toml):
+// - planner has `delegate_name = "plan"`, so the orchestrator LLM sees a
+// tool named "plan" synthesised by collect_orchestrator_tools.
// - The tool takes { "prompt": string, ... } per ArchetypeDelegationTool schema.
-// - The orchestrator TOML lists "researcher" in its subagents.allowlist.
+// - The orchestrator TOML lists "planner" in its subagents.allowlist.
// - AgentDefinitionRegistry must be initialised (done in boot_stack) for the
-// delegation tool to be synthesised; without it the call becomes "Unknown tool: research".
+// delegation tool to be synthesised; without it the call becomes "Unknown tool: plan".
//
// Actual LLM request ordering (with registry init):
-// request[0] = orchestrator → model returns { tool_calls: [research(...)] }
-// request[1] = researcher subagent inner loop → model returns canary text
+// request[0] = orchestrator → model returns { tool_calls: [plan(...)] }
+// request[1] = planner subagent inner loop → model returns canary text
// request[2] = orchestrator synthesis → model returns final text with canary
-/// Orchestrator delegates to researcher via the `research` tool (delegate_name
-/// on the researcher agent definition); the researcher subagent runs its own
-/// inner LLM call; the final orchestrator synthesis reply contains the researcher
+/// Orchestrator delegates to planner via the `plan` tool (delegate_name
+/// on the planner agent definition); the planner subagent runs its own
+/// inner LLM call; the final orchestrator synthesis reply contains the planner
/// canary. Three upstream requests prove the full delegation path ran.
#[test]
fn subagent_delegation_happy_path() {
@@ -1020,15 +1020,15 @@ fn subagent_delegation_happy_path() {
async fn subagent_delegation_happy_path_inner() {
let _lock = env_lock();
reset_script(vec![
- // request[0]: Orchestrator calls the `research` tool (researcher's delegate_name).
+ // request[0]: Orchestrator calls the `plan` tool (planner's delegate_name).
tool_call_completion(
- "research",
+ "plan",
json!({ "prompt": "Find the marker phrase", "blocking": true }),
),
- // request[1]: Researcher subagent inner LLM call returns its canary.
- text_completion("RESEARCHER_CANARY_42 is the marker."),
- // request[2]: Orchestrator receives the researcher result and synthesizes.
- text_completion("Done. The result is: RESEARCHER_CANARY_42"),
+ // request[1]: Planner subagent inner LLM call returns its canary.
+ text_completion("PLANNER_CANARY_42 is the marker."),
+ // request[2]: Orchestrator receives the planner result and synthesizes.
+ text_completion("Done. The result is: PLANNER_CANARY_42"),
]);
let stack = boot_stack().await;
@@ -1042,7 +1042,7 @@ async fn subagent_delegation_happy_path_inner() {
300,
"harness-subagent",
"thread-sub",
- "research the marker",
+ "plan around the marker",
)
.await;
@@ -1058,13 +1058,13 @@ async fn subagent_delegation_happy_path_inner() {
.and_then(Value::as_str)
.unwrap_or_else(|| panic!("chat_done missing 'full_response': {done}"));
assert!(
- full_response.contains("RESEARCHER_CANARY_42"),
- "final response missing researcher canary; full_response: {full_response}\nevent: {done}"
+ full_response.contains("PLANNER_CANARY_42"),
+ "final response missing planner canary; full_response: {full_response}\nevent: {done}"
);
// Delegation evidenced by ≥3 captured upstream requests:
- // request[0] = orchestrator turn: research tool call returned
- // request[1] = researcher subagent inner LLM call: canary text returned
+ // request[0] = orchestrator turn: plan tool call returned
+ // request[1] = planner subagent inner LLM call: canary text returned
// request[2] = orchestrator synthesis: canary forwarded in final reply
//
// NOTE: a completed turn's snapshot is now RETAINED (lifecycle `Completed`)
@@ -1075,7 +1075,7 @@ async fn subagent_delegation_happy_path_inner() {
let requests = with_captured(|c| c.clone());
assert!(
requests.len() >= 3,
- "expected ≥3 upstream requests (orchestrator + researcher + orchestrator synthesis), \
+ "expected ≥3 upstream requests (orchestrator + planner + orchestrator synthesis), \
got {};\nall requests: {}",
requests.len(),
serde_json::to_string_pretty(&requests).unwrap_or_default()
@@ -1090,7 +1090,7 @@ async fn subagent_delegation_happy_path_inner() {
serde_json::to_string_pretty(&requests).unwrap_or_default()
);
- // request[1] (researcher subagent) must have different system/message content
+ // request[1] (planner subagent) must have different system/message content
// from request[0] (orchestrator) — proves a genuinely different agent context
// ran, not the same orchestrator re-called.
let req0_sys = requests
@@ -1106,7 +1106,7 @@ async fn subagent_delegation_happy_path_inner() {
assert_ne!(
req0_sys, req1_sys,
"request[0] and request[1] share identical first-message content — \
- researcher subagent did not build its own context; \
+ planner subagent did not build its own context; \
content: {req0_sys:?}"
);
@@ -1683,7 +1683,7 @@ async fn approval_gate_deny_flow_inner() {
// code_executor has delegate_name = "run_code" (crates/openhuman-core/src/agent/registry/
// agents/code_executor/agent.toml:3). The orchestrator synthesizes a `run_code`
// delegation tool from this. code_executor has file_write in its tool surface.
-// The researcher agent does NOT have file_write.
+// The planner agent (read-only) does NOT have file_write.
//
// Actual LLM request ordering:
// request[0] = orchestrator → run_code delegation tool call
@@ -2126,8 +2126,8 @@ async fn provider_error_retry_inner() {
// parallel_subagent_fanout:
// spawn_parallel_agents is in the orchestrator's named tools (agent.toml:165)
// and is registered via ops.rs:163. Requires ≥2 tasks, each { agent_id, prompt }.
-// The orchestrator's subagents.allowlist includes "researcher", so
-// agent_id:"researcher" is valid. children run via join_all (spawn_parallel_agents.rs
+// The orchestrator's subagents.allowlist includes "planner", so
+// agent_id:"planner" is valid. children run via join_all (spawn_parallel_agents.rs
// ~line 322 — "let futures = prepared.into_iter().map(…)"). Both children
// consume from the same global FIFO scripted-response queue. Because
// join_all spawns futures concurrently but the queue pop is under a Mutex,
@@ -2135,14 +2135,14 @@ async fn provider_error_retry_inner() {
// carry distinct canaries; the synthesis quotes both.
// LLM request ordering (4 upstream calls):
// request[0] = orchestrator → spawn_parallel_agents tool call
-// request[1,2] = researcher child 1 & child 2 (order nondeterministic,
+// request[1,2] = planner child 1 & child 2 (order nondeterministic,
// both return distinct canaries)
// request[3] = orchestrator synthesis with both canaries
//
// multi_hop_delegation_chain:
-// Depth-1 subagents (researcher, code_executor, etc.) do NOT have spawn
-// tools in their named lists. Verified: researcher/agent.toml has only web/
-// file tools; code_executor/agent.toml has code/file tools. Neither contains
+// Depth-1 subagents (planner, code_executor, etc.) do NOT have spawn
+// tools in their named lists. Verified: planner/agent.toml has only read-only
+// web/file/memory tools; code_executor/agent.toml has code/file tools. Neither contains
// spawn_subagent, spawn_worker_thread, or spawn_parallel_agents. The only
// agents with spawn tools are orchestrator and trigger_reactor (loader.rs:383,
// 527). trigger_reactor is not in the orchestrator's subagents.allowlist.
@@ -2150,18 +2150,18 @@ async fn provider_error_retry_inner() {
// with the current built-in agent graph; the cap is a safety net for
// runtime-registered agents.
//
-// Fallback (plan Task 9, step 9.2 fallback): orchestrator → researcher (via
-// `research`) → researcher scripted to call ask_user_clarification (not in
-// researcher's named tools → SubagentToolSource::execute returns a blocked
-// response, tool loop continues) → researcher second LLM call returns
-// DEPTH2_CANARY text → dispatch_subagent forwards as `research` tool result
+// Fallback (plan Task 9, step 9.2 fallback): orchestrator → planner (via
+// `plan`) → planner scripted to call ask_user_clarification (not in
+// planner's named tools → SubagentToolSource::execute returns a blocked
+// response, tool loop continues) → planner second LLM call returns
+// DEPTH2_CANARY text → dispatch_subagent forwards as `plan` tool result
// → orchestrator synthesis. The three-level synthesis path (user turn →
-// researcher subagent → tool-loop continuation → orchestrator synthesis) is
+// planner subagent → tool-loop continuation → orchestrator synthesis) is
// the deepest path reachable with built-in agents without src/ changes.
// LLM request ordering (4 upstream calls):
-// request[0] = orchestrator → `research` delegation
-// request[1] = researcher (inner loop) → ask_user_clarification (blocked)
-// request[2] = researcher (inner loop continuation) → DEPTH2_CANARY text
+// request[0] = orchestrator → `plan` delegation
+// request[1] = planner (inner loop) → ask_user_clarification (blocked)
+// request[2] = planner (inner loop continuation) → DEPTH2_CANARY text
// request[3] = orchestrator synthesis
/// Two `spawn_async_subagent` calls issued together really do put two workers
@@ -2213,11 +2213,11 @@ async fn parallel_subagent_fanout_inner() {
tool_calls_completion(&[
(
"spawn_async_subagent",
- json!({ "agent_id": "researcher", "prompt": "Find PARALLEL_ALPHA_CANARY" }),
+ json!({ "agent_id": "planner", "prompt": "Find PARALLEL_ALPHA_CANARY" }),
),
(
"spawn_async_subagent",
- json!({ "agent_id": "researcher", "prompt": "Find PARALLEL_BETA_CANARY" }),
+ json!({ "agent_id": "planner", "prompt": "Find PARALLEL_BETA_CANARY" }),
),
]),
text_completion("Spawned two workers; results will arrive as they land."),
@@ -2309,18 +2309,20 @@ async fn parallel_subagent_fanout_inner() {
);
}
-/// SubagentToolSource returns error); researcher loops and returns DEPTH2_CANARY;
+/// Orchestrator delegates to planner via `plan`; the planner calls
+/// ask_user_clarification (not in its named tools, so SubagentToolSource
+/// returns error); planner loops and returns DEPTH2_CANARY;
/// dispatch_subagent forwards the result; orchestrator synthesizes.
///
-/// Depth behavior discovered: researcher/agent.toml has only web/file tools
-/// (no spawn_subagent, spawn_worker_thread, spawn_parallel_agents). MAX_SPAWN_DEPTH=3
+/// Depth behavior discovered: planner/agent.toml has only read-only web/file/memory
+/// tools (no spawn_subagent, spawn_worker_thread, spawn_parallel_agents). MAX_SPAWN_DEPTH=3
/// (spawn_depth_context.rs:16) is unreachable with built-in agents; it guards
/// runtime/workspace agents. The three-level synthesis (user-turn root →
-/// researcher subagent → orchestrator synthesis) is the deepest path available
+/// planner subagent → orchestrator synthesis) is the deepest path available
/// without src/ changes. Documented per plan Task 9 step 9.2 fallback.
///
/// Intentionally shares the blocked-clarification mechanic with
-/// `scheduling_clarification_flow`; differs in delegate surface (research vs
+/// `scheduling_clarification_flow`; differs in delegate surface (plan vs
/// schedule_task) and single-turn shape.
#[test]
fn multi_hop_delegation_chain() {
@@ -2333,24 +2335,24 @@ fn multi_hop_delegation_chain() {
async fn multi_hop_delegation_chain_inner() {
let _lock = env_lock();
reset_script(vec![
- // request[0]: Orchestrator delegates to researcher via `research`
- // (researcher's delegate_name, agent.toml:3).
+ // request[0]: Orchestrator delegates to planner via `plan`
+ // (planner's delegate_name, agent.toml:3).
tool_call_completion(
- "research",
+ "plan",
json!({ "prompt": "deep question", "blocking": true }),
),
- // request[1]: Researcher first inner LLM call → scripts ask_user_clarification.
- // ask_user_clarification is NOT in researcher's named tools (researcher/agent.toml:21-50),
+ // request[1]: Planner first inner LLM call → scripts ask_user_clarification.
+ // ask_user_clarification is NOT in planner's named tools (planner/agent.toml `[tools] named`),
// so SubagentToolSource returns a blocked/error result (tool_source.rs:36).
- // The researcher subagent loop continues to a second LLM call.
+ // The planner subagent loop continues to a second LLM call.
tool_call_completion(
"ask_user_clarification",
json!({ "question": "depth-2 clarification?" }),
),
- // request[2]: Researcher second inner LLM call → text result.
- // This becomes the `research` tool result forwarded by dispatch_subagent.
+ // request[2]: Planner second inner LLM call → text result.
+ // This becomes the `plan` tool result forwarded by dispatch_subagent.
text_completion("DEPTH2_CANARY"),
- // request[3]: Orchestrator receives the research result and synthesizes.
+ // request[3]: Orchestrator receives the plan result and synthesizes.
text_completion("Final answer: DEPTH2_CANARY"),
]);
let stack = boot_stack().await;
@@ -2385,27 +2387,27 @@ async fn multi_hop_delegation_chain_inner() {
);
// ≥4 upstream requests prove the full delegation path ran (≥3 would
- // false-pass if the researcher inner loop early-exited):
- // request[0] = orchestrator (research call),
- // request[1] = researcher first iter (ask_user_clarification → blocked),
- // request[2] = researcher second iter (DEPTH2_CANARY text),
+ // false-pass if the planner inner loop early-exited):
+ // request[0] = orchestrator (plan call),
+ // request[1] = planner first iter (ask_user_clarification → blocked),
+ // request[2] = planner second iter (DEPTH2_CANARY text),
// request[3] = orchestrator synthesis.
let requests = with_captured(|c| c.clone());
assert!(
requests.len() >= 4,
- "expected ≥4 upstream requests (orchestrator + researcher x2 + synthesis), got {};\
+ "expected ≥4 upstream requests (orchestrator + planner x2 + synthesis), got {};\
\nrequests: {}",
requests.len(),
serde_json::to_string_pretty(&requests).unwrap_or_default()
);
- // No unknown-tool result for `research` — delegation was synthesised correctly.
- // Scoped to `research`: the researcher's `ask_user_clarification` call IS
+ // No unknown-tool result for `plan` — delegation was synthesised correctly.
+ // Scoped to `plan`: the planner's `ask_user_clarification` call IS
// rejected as unknown by design (see the ordering note above), so a blanket
// check would fail on the very mechanic this test exercises.
assert!(
- !captured_requests_reject_tool_as_unknown(&requests, "research"),
- "found an unknown-tool result — `research` delegation was not synthesised; requests: {}",
+ !captured_requests_reject_tool_as_unknown(&requests, "plan"),
+ "found an unknown-tool result — `plan` delegation was not synthesised; requests: {}",
serde_json::to_string_pretty(&requests).unwrap_or_default()
);
@@ -5135,7 +5137,7 @@ async fn cancelling_a_running_background_subagent_settles_it_inner() {
reset_script(vec![
tool_calls_completion(&[(
"spawn_async_subagent",
- json!({ "agent_id": "researcher", "prompt": "Find CANCEL_E2E_CANARY" }),
+ json!({ "agent_id": "planner", "prompt": "Find CANCEL_E2E_CANARY" }),
)]),
text_completion("Spawned a worker; its result will arrive later."),
text_completion("worker would have finished here"),