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: add coverage for subagent, workflow, lease, and web chat paths
Steven Enamakel88b5c7b06dfd
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rsindex e230176aaf..0af4d7ecd5 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_tests.rs@@ -331,9 +331,9 @@ async fn each_agent_dedupes_its_own_in_flight_sub_agents() {let alpha = test_agent_context(&root, "alpha");let beta = test_agent_context(&root, "beta");- let alpha_map = CoreContext::scope(Arc::clone(&alpha), async { host_in_flight() }).await;- let beta_map = CoreContext::scope(beta, async { host_in_flight() }).await;- let alpha_again = CoreContext::scope(alpha, async { host_in_flight() }).await;+ let alpha_map = CoreContext::scope(Arc::clone(&alpha), async { host_in_flight(&crate::core::runtime::DispatchCtx::ambient()) }).await;+ let beta_map = CoreContext::scope(beta, async { host_in_flight(&crate::core::runtime::DispatchCtx::ambient()) }).await;+ let alpha_again = CoreContext::scope(alpha, async { host_in_flight(&crate::core::runtime::DispatchCtx::ambient()) }).await;assert!(!Arc::ptr_eq(&alpha_map, &beta_map));assert!(Arc::ptr_eq(&alpha_map, &alpha_again));diff --git a/crates/openhuman-core/src/agent/tools/run_workflow_tests.rs b/crates/openhuman-core/src/agent/tools/run_workflow_tests.rsindex e4528950cd..e4afe44ed9 100644--- a/crates/openhuman-core/src/agent/tools/run_workflow_tests.rs+++ b/crates/openhuman-core/src/agent/tools/run_workflow_tests.rs@@ -119,7 +119,7 @@ async fn unknown_workflow_id_does_not_burn_a_spawn_slot() {// DELTA is zero (the counter is global + monotonic, so absolute value is// shared with the backstop test — hence the serial lock + delta check).let _s = guard_serial().lock().await;- let before = super::guard::total_spawns();+ let before = super::guard::total_spawns(&crate::core::runtime::DispatchCtx::ambient());let t = RunWorkflowTool::new();// wait_seconds: 0 → fire-and-forget path (no await slot taken); the// unknown id makes the spawn fail before accounting.@@ -136,7 +136,7 @@ async fn unknown_workflow_id_does_not_burn_a_spawn_slot() {"error should reference the unknown workflow: {}",res.output());- let after = super::guard::total_spawns();+ let after = super::guard::total_spawns(&crate::core::runtime::DispatchCtx::ambient());assert_eq!(before, after,"a rejected spawn must not increment the spawn backstop counter"@@ -154,7 +154,7 @@ fn account_spawn_trips_the_process_backstop() {// path does, and that runs in a separate process).let mut last = Ok(());for _ in 0..600 {- last = super::guard::account_spawn();+ last = super::guard::account_spawn(&crate::core::runtime::DispatchCtx::ambient());if last.is_err() {break;}diff --git a/crates/openhuman-core/src/profiles/lease_tests.rs b/crates/openhuman-core/src/profiles/lease_tests.rsindex 858607da05..88f58e8383 100644--- a/crates/openhuman-core/src/profiles/lease_tests.rs+++ b/crates/openhuman-core/src/profiles/lease_tests.rs@@ -167,7 +167,7 @@ async fn renewal_keeps_the_lease_and_a_lost_lease_fences_the_profile() {let turn = tokio_util::sync::CancellationToken::new();CoreContext::scope(Arc::clone(state.context()),- crate::web_chat::track_parallel_turn_for_test("t1", "req-1", turn.clone()),+ crate::web_chat::track_parallel_turn_for_test(&crate::core::runtime::DispatchCtx::ambient(), "t1", "req-1", turn.clone()),).await;assert_eq!(diff --git a/crates/openhuman-core/src/test_support/introspect.rs b/crates/openhuman-core/src/test_support/introspect.rsindex e9fb057c20..7577e199d9 100644--- a/crates/openhuman-core/src/test_support/introspect.rs+++ b/crates/openhuman-core/src/test_support/introspect.rs@@ -303,8 +303,10 @@ pub struct InFlightResult {pub entries: Vec<InFlightEntryView>,}-pub async fn in_flight_chats() -> Result<Outcome<InFlightResult>, String> {- let entries: Vec<InFlightEntryView> = in_flight_entries_for_test()+pub async fn in_flight_chats(+ ctx: &crate::core::runtime::DispatchCtx,+) -> Result<Outcome<InFlightResult>, String> {+ let entries: Vec<InFlightEntryView> = in_flight_entries_for_test(ctx).await.into_iter().map(|(key, request_id)| InFlightEntryView { key, request_id })diff --git a/crates/openhuman-core/src/test_support/schemas.rs b/crates/openhuman-core/src/test_support/schemas.rsindex 54ae73b65d..94a19485d4 100644--- a/crates/openhuman-core/src/test_support/schemas.rs+++ b/crates/openhuman-core/src/test_support/schemas.rs@@ -304,8 +304,8 @@ fn handle_read_workspace_file(_ctx: DispatchCtx, params: Map<String, Value>) ->})}-fn handle_in_flight_chats(_ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {- Box::pin(async move { to_json(introspect::in_flight_chats().await?) })+fn handle_in_flight_chats(ctx: DispatchCtx, _params: Map<String, Value>) -> ControllerFuture {+ Box::pin(async move { to_json(introspect::in_flight_chats(&ctx).await?) })}fn handle_wallet_prepared_quotes(diff --git a/crates/openhuman-core/src/web_chat/ops/state_tests.rs b/crates/openhuman-core/src/web_chat/ops/state_tests.rsindex e6893ffb52..f24b269476 100644--- a/crates/openhuman-core/src/web_chat/ops/state_tests.rs+++ b/crates/openhuman-core/src/web_chat/ops/state_tests.rs@@ -80,7 +80,7 @@ async fn two_profiles_on_the_same_thread_id_hold_two_keys() {#[tokio::test]async fn a_user_cancel_under_the_fence_placeholder_id_keeps_the_callers_client() {let token = tokio_util::sync::CancellationToken::new();- track_parallel_turn_for_test("fence-thread", "fence-req", token.clone()).await;+ track_parallel_turn_for_test(&crate::core::runtime::DispatchCtx::ambient(), "fence-thread", "fence-req", token.clone()).await;let mut events = crate::web_chat::subscribe_web_channel_events();crate::web_chat::ops::channel_ops::cancel_chat_scoped(diff --git a/crates/openhuman-core/src/web_chat/web_tests.rs b/crates/openhuman-core/src/web_chat/web_tests.rsindex d08eb51b90..4ff414a620 100644--- a/crates/openhuman-core/src/web_chat/web_tests.rs+++ b/crates/openhuman-core/src/web_chat/web_tests.rs@@ -75,7 +75,7 @@ fn fp(async fn wait_for_in_flight<F: Fn(&[(String, String)]) -> bool>(pred: F) -> Vec<(String, String)> {timeout(Duration::from_secs(5), async {loop {- let entries = in_flight_entries_for_test().await;+ let entries = in_flight_entries_for_test(&crate::core::runtime::DispatchCtx::ambient()).await;if pred(&entries) {return entries;}@@ -110,7 +110,7 @@ fn make_block() -> TestRunChatTaskBlock {async fn wait_for_parallel<F: Fn(&[(String, String)]) -> bool>(pred: F) -> Vec<(String, String)> {timeout(Duration::from_secs(5), async {loop {- let entries = parallel_in_flight_entries_for_test().await;+ let entries = parallel_in_flight_entries_for_test(&crate::core::runtime::DispatchCtx::ambient()).await;if pred(&entries) {return entries;}diff --git a/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rsindex 150c48d556..f18eab8b63 100644--- a/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rs+++ b/crates/openhuman-core/src/web_chat/web_tests_queue_acceptance_tests.rs@@ -67,7 +67,7 @@ async fn web_queue_retains_typed_queued_turn_metadata() {// This drains the actual in-flight host queue, not a standalone// RunQueue<String>, proving the concrete public DTO survives admission.- let queued = drain_queued_turns_for_test(thread_id, QueueLane::Followup).await;+ let queued = drain_queued_turns_for_test(&crate::core::runtime::DispatchCtx::ambient(), thread_id, QueueLane::Followup).await;assert_eq!(queued.len(), 1);let queued = &queued[0];assert_eq!(queued.text, "defer this exact payload");@@ -222,13 +222,13 @@ async fn cancellation_discards_pending_lanes_before_a_replacement_turn() {.await.expect("replacement queue status should be available");assert_eq!(replacement.value["total"], 0);- assert!(drain_queued_turns_for_test(thread_id, QueueLane::Followup)+ assert!(drain_queued_turns_for_test(&crate::core::runtime::DispatchCtx::ambient(), thread_id, QueueLane::Followup).await.is_empty());- assert!(drain_queued_turns_for_test(thread_id, QueueLane::Steer)+ assert!(drain_queued_turns_for_test(&crate::core::runtime::DispatchCtx::ambient(), thread_id, QueueLane::Steer).await.is_empty());- assert!(drain_queued_turns_for_test(thread_id, QueueLane::Collect)+ assert!(drain_queued_turns_for_test(&crate::core::runtime::DispatchCtx::ambient(), thread_id, QueueLane::Collect).await.is_empty());@@ -485,7 +485,7 @@ async fn chat_done_is_published_only_after_the_in_flight_slot_is_released() {.await.expect("chat_done after the slot is released");assert!(- !in_flight_entries_for_test()+ !in_flight_entries_for_test(&crate::core::runtime::DispatchCtx::ambient()).await.iter().any(|(key, _)| key == thread_id),diff --git a/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs b/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rsindex c9fbb43e64..6229bc1e27 100644--- a/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs+++ b/crates/openhuman-core/src/web_chat/web_tests_session_and_concurrency_tests.rs@@ -459,7 +459,7 @@ async fn parallel_turn_runs_concurrently_with_primary_on_same_thread() {wait_for_parallel(|e| e.iter().any(|(_, t)| t == thread_id)).await;// Primary is still in-flight — the parallel send did not interrupt it.assert!(- in_flight_entries_for_test()+ in_flight_entries_for_test(&crate::core::runtime::DispatchCtx::ambient()).await.iter().any(|(k, _)| k == thread_id),