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(orchestration): add coverage for async subagent and worker thread spawning
Steven Enamakelf17271a160d1
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rsindex 0d9b770776..91c84c80e1 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_tests.rs@@ -1,5 +1,5 @@use super::*;-use crate::agent::harness::fork_context::{with_parent_context, ParentExecutionContext};+use crate::agent::harness::fork_context::ParentExecutionContext;use crate::agent::harness::host_definition::AgentDefinitionRegistry;use crate::config::AgentConfig;use std::collections::HashSet;@@ -483,9 +483,9 @@ async fn missing_prompt_returns_error() {/// `agent` node, CLI, cron) must get a clear, actionable error instead of/// silently accepting the spawn and later dropping its result in/// `background_delivery`'s "headless batch" path. Sets up a real parent-/// turn context (so the call gets past the `current_parent()` /-/// allowlist / registry checks) but deliberately does NOT wrap the call-/// without an explicit parent thread, so the child has no thread — the exact+/// turn context (so the call gets past the parent-context /+/// allowlist / registry checks) but deliberately gives the call+/// no explicit parent thread, so the child has no thread — the exact/// condition that used to sail through to `tokio::spawn` and lose the/// result.#[tokio::test]@@ -493,16 +493,18 @@ async fn errors_clearly_when_no_parent_thread_for_delivery() {let _ = AgentDefinitionRegistry::init_global_builtins();let workspace = tempfile::TempDir::new().expect("workspace");- let result = with_parent_context(parent_context(workspace.path()), async {- SpawnAsyncSubagentTool::new()- .execute(json!({+ let result = SpawnAsyncSubagentTool::new()+ .execute_under_parent(+ json!({"agent_id": "task_manager_agent","prompt": "investigate x",- }))- .await- })- .await- .unwrap();+ }),+ ToolCallOptions::default(),+ None,+ parent_context(workspace.path()),+ )+ .await+ .unwrap();assert!(result.is_error);let out = result.output();@@ -537,20 +539,18 @@ async fn guard_does_not_fire_when_parent_thread_is_bound() {let workspace = tempfile::TempDir::new().expect("workspace");let thread = ThreadContext("t-parent");- let result = with_parent_context(parent_context(workspace.path()), async {- SpawnAsyncSubagentTool::new()- .execute_with_context(- json!({- "agent_id": "task_manager_agent",- "prompt": "investigate x",- }),- ToolCallOptions::default(),- Some(&thread),- )- .await- })- .await- .unwrap();+ let result = SpawnAsyncSubagentTool::new()+ .execute_under_parent(+ json!({+ "agent_id": "task_manager_agent",+ "prompt": "investigate x",+ }),+ ToolCallOptions::default(),+ Some(&thread),+ parent_context(workspace.path()),+ )+ .await+ .unwrap();assert!(!result.output().contains("no parent chat thread"),diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rsindex e5ea00c5c2..2269109022 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread_tests.rs@@ -1,5 +1,4 @@use super::*;-use crate::agent::harness::fork_context::with_parent_context;use crate::agent::harness::ParentExecutionContext;use crate::threads::store::CreateConversationThread;use std::path::PathBuf;@@ -120,21 +119,24 @@ async fn rejects_agent_outside_parent_allowlist() {let temp = TempDir::new().unwrap();let parent = test_parent_ctx(temp.path().to_path_buf());- with_parent_context(parent, async {- let tool = SpawnWorkerThreadTool::new();- let result = tool- .execute(json!({+ let live = super::live_parent_run_context("worker-allowlist-test", parent);+ let tool = SpawnWorkerThreadTool::new();+ let result = tool+ .execute_with_live_parent_context(+ json!({"agent_id": "task_manager_agent","prompt": "do it","task_title": "Task"- }))- .await- .unwrap();+ }),+ None,+ live.data.child(),+ Some(&live),+ )+ .await+ .unwrap();- assert!(result.is_error);- assert!(result.output().contains(- "spawn_worker_thread: agent 'task_manager_agent' is not in parent agent 'orchestrator' subagents.allowlist"- ));- })- .await;+ assert!(result.is_error);+ assert!(result.output().contains(+ "spawn_worker_thread: agent 'task_manager_agent' is not in parent agent 'orchestrator' subagents.allowlist"+ ));}