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 subagent steering and recovery
Steven Enamakel594528cdfa9a
diff --git a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rsindex e3ef9f9e2f..074d2999c8 100644--- a/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/background_completions_tests.rs@@ -158,11 +158,11 @@ fn clear_all_withdraws_every_pending_completion() {record(w, "sess-c1", "sub-1", "a", Some("t1"));record(w, "sess-c2", "sub-2", "b", Some("t2"));- let removed = clear_all(w);+ let removed = clear_all(&crate::core::runtime::DispatchCtx::ambient(), w);assert_eq!(removed, 2);assert!(pending_ids(w, "t1").is_empty());assert!(pending_ids(w, "t2").is_empty());- assert_eq!(clear_all(w), 0);+ assert_eq!(clear_all(&crate::core::runtime::DispatchCtx::ambient(), w), 0);}#[test]@@ -173,7 +173,7 @@ fn clear_all_is_scoped_to_its_workspace() {record(purged.path(), "sess-p", "sub-1", "a", Some("t-purged"));record(other.path(), "sess-o", "sub-2", "b", Some("t-other"));- assert_eq!(clear_all(purged.path()), 1);+ assert_eq!(clear_all(&crate::core::runtime::DispatchCtx::ambient(), purged.path()), 1);assert!(pending_ids(purged.path(), "t-purged").is_empty());assert_eq!(@@ -522,7 +522,7 @@ fn clear_all_also_withdraws_a_completion_a_delivery_has_leased() {1);- assert_eq!(clear_all(w), 1);+ assert_eq!(clear_all(&crate::core::runtime::DispatchCtx::ambient(), w), 1);assert!(pending_ids(w, "thread-leased").is_empty());assert_eq!(diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rsindex bd5ae50cd1..d6422013fb 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_steering_tests.rs@@ -6,7 +6,7 @@ async fn steer_pushes_into_the_subagent_queue() {let rq = run_queue();let tx = register_test("task-steer", "session-A", rq.clone());- steer(+ steer(&crate::core::runtime::DispatchCtx::ambient(),"task-steer","session-A","refocus on memory safety".into(),@@ -19,7 +19,7 @@ async fn steer_pushes_into_the_subagent_queue() {assert_eq!(status.steers, 1, "steer should land in the steer lane");// collect mode goes to the collect lane- steer(+ steer(&crate::core::runtime::DispatchCtx::ambient(),"task-steer","session-A","extra context".into(),@@ -45,7 +45,7 @@ async fn steer_prefers_registered_tinyagents_handle() {let task_id = TaskId::new("task-registered-steer");shared_steering_registry().register(task_id.clone(), handle.clone());- steer(+ steer(&crate::core::runtime::DispatchCtx::ambient(),"task-registered-steer","session-A","refocus".into(),@@ -80,7 +80,7 @@ async fn steer_rejects_cross_parent_and_unknown() {let _tx = register_test("task-owned", "session-owner", rq);assert_eq!(- steer(+ steer(&crate::core::runtime::DispatchCtx::ambient(),"task-owned","session-intruder","x".into(),@@ -90,7 +90,7 @@ async fn steer_rejects_cross_parent_and_unknown() {Err(SteerError::NotOwned));assert_eq!(- steer(+ steer(&crate::core::runtime::DispatchCtx::ambient(),"task-missing","session-owner","x".into(),@@ -112,7 +112,7 @@ async fn steer_after_terminal_is_rejected() {});assert_eq!(- steer("task-term", "session-A", "x".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-term", "session-A", "x".into(), QueueLane::Steer).await,Err(SteerError::AlreadyDone));prune("task-term");@@ -125,7 +125,7 @@ async fn detached_subagent_rejects_followup_lane() {let _tx = register_test("task-no-followup", "session-A", rq.clone());assert_eq!(- steer(+ steer(&crate::core::runtime::DispatchCtx::ambient(),"task-no-followup","session-A","not a new turn".into(),diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rsindex 09dc46a376..30e5284fcd 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tenant_tests.rs@@ -60,7 +60,7 @@ impl Worker {let (tx, rx) = status_channel();let task_handle = tokio::spawn(std::future::pending::<()>());let abort = task_handle.abort_handle();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),task.clone(),"researcher".into(),PARENT.into(),@@ -366,7 +366,7 @@ async fn same_parent_resolution_and_wait_refuse_foreign_workers() {Err(WaitError::NotOwned)));assert!(matches!(- wait(&pair.a.task, PARENT, Duration::ZERO).await,+ wait(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT, Duration::ZERO).await,Err(WaitError::NotOwned)));assert_eq!(@@ -388,11 +388,11 @@ async fn same_parent_agent_steering_refuses_foreign_worker() {let pair = Pair::new();CoreContext::scope(pair.bob.clone(), async {assert_eq!(- steer(&pair.a.task, PARENT, "foreign".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT, "foreign".into(), QueueLane::Steer).await,Err(SteerError::NotOwned));assert_eq!(pair.a.queue.status().await.steers, 0);- steer(&pair.b.task, PARENT, "own".into(), QueueLane::Steer)+ steer(&crate::core::runtime::DispatchCtx::ambient(), &pair.b.task, PARENT, "own".into(), QueueLane::Steer).await.unwrap();assert_eq!(pair.b.queue.status().await.steers, 1);@@ -467,7 +467,7 @@ async fn missing_saas_scope_cannot_observe_or_control_workers() {Err(WaitError::NotOwned)));assert_eq!(- steer(&pair.a.task, PARENT, "unscoped".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), &pair.a.task, PARENT, "unscoped".into(), QueueLane::Steer).await,Err(SteerError::NotOwned));assert_eq!(diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rsindex f79a3debf0..fff0705b13 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_tests.rs@@ -88,7 +88,7 @@ fn register_test_with_thread(rq: Arc<RunQueue<QueuedTurn>>,) -> watch::Sender<DetachedSubagentStatus> {let (tx, rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),task_id.into(),"researcher".into(),parent_session.into(),@@ -161,7 +161,7 @@ async fn task_id_for_session_enforces_parent_ownership() {let _guard = test_guard_async().await;let rq = run_queue();let (tx, rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-session".into(),"researcher".into(),"session-owner".into(),@@ -194,7 +194,7 @@ async fn task_id_for_session_enforces_parent_ownership() {async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {let _guard = test_guard_async().await;let (tx_a, rx_a) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-fleet-a".into(),"researcher".into(),"fleet-parent".into(),@@ -208,7 +208,7 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {).expect("fixture registration admitted");let (tx_b, rx_b) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-fleet-b".into(),"code_executor".into(),"fleet-parent".into(),@@ -223,7 +223,7 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {.expect("fixture registration admitted");// A worker owned by a different parent must not leak into the snapshot.let (tx_other, rx_other) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-fleet-other".into(),"researcher".into(),"other-parent".into(),@@ -366,7 +366,7 @@ async fn snapshot_and_block_scope_to_parent_and_reflect_live_status() {async fn resume_ref_for_task_includes_resume_fields_and_enforces_ownership() {let _guard = test_guard_async().await;let (tx, rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-resume".into(),"researcher".into(),"session-owner".into(),@@ -403,7 +403,7 @@ async fn resume_ref_for_task_includes_resume_fields_and_enforces_ownership() {async fn task_id_for_session_prefers_live_task_over_terminal_task() {let _guard = test_guard_async().await;let (old_tx, old_rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-old".into(),"researcher".into(),"session-owner".into(),@@ -421,7 +421,7 @@ async fn task_id_for_session_prefers_live_task_over_terminal_task() {iterations: 1,});let (_new_tx, new_rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-new".into(),"researcher".into(),"session-owner".into(),@@ -458,7 +458,7 @@ async fn wait_returns_completion_once_published() {drop(tx);});- let outcome = wait("task-wait", "session-A", Duration::from_secs(5))+ let outcome = wait(&crate::core::runtime::DispatchCtx::ambient(), "task-wait", "session-A", Duration::from_secs(5)).await.expect("wait should resolve");match outcome {@@ -471,7 +471,7 @@ async fn wait_returns_completion_once_published() {// pruned after a terminal waitassert!(matches!(- wait("task-wait", "session-A", Duration::from_millis(10)).await,+ wait(&crate::core::runtime::DispatchCtx::ambient(), "task-wait", "session-A", Duration::from_millis(10)).await,Err(WaitError::Unknown)));}@@ -482,7 +482,7 @@ async fn wait_times_out_and_leaves_entry_intact() {let rq = run_queue();let _tx = register_test("task-slow", "session-A", rq);- let outcome = wait("task-slow", "session-A", Duration::from_millis(20))+ let outcome = wait(&crate::core::runtime::DispatchCtx::ambient(), "task-slow", "session-A", Duration::from_millis(20)).await.expect("wait should resolve");assert!(matches!(@@ -491,7 +491,7 @@ async fn wait_times_out_and_leaves_entry_intact() {));// still steerable after a timed-out wait- assert!(steer(+ assert!(steer(&crate::core::runtime::DispatchCtx::ambient(),"task-slow","session-A","still here".into(),@@ -518,20 +518,20 @@ async fn cancel_for_thread_aborts_only_matching_entries() {// The two cancelled entries are gone (steer can't find them).assert_eq!(- steer("task-tA-1", "session-A", "x".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-tA-1", "session-A", "x".into(), QueueLane::Steer).await,Err(SteerError::Unknown));assert_eq!(- steer("task-tA-2", "session-A", "x".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-tA-2", "session-A", "x".into(), QueueLane::Steer).await,Err(SteerError::Unknown));// Non-matching entries stay live and steerable.- assert!(steer("task-tB", "session-A", "x".into(), QueueLane::Steer)+ assert!(steer(&crate::core::runtime::DispatchCtx::ambient(), "task-tB", "session-A", "x".into(), QueueLane::Steer).await.is_ok());assert!(- steer("task-headless", "session-A", "x".into(), QueueLane::Steer)+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-headless", "session-A", "x".into(), QueueLane::Steer).await.is_ok());@@ -566,7 +566,7 @@ async fn cancel_by_task_returns_metadata_and_removes_entry() {// Entry is gone — steer can no longer find it, and a second cancel is a no-op.assert_eq!(- steer("task-cbt", "session-Z", "x".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-cbt", "session-Z", "x".into(), QueueLane::Steer).await,Err(SteerError::Unknown));assert!(cancel_by_task(&crate::core::runtime::DispatchCtx::ambient(), "task-cbt").is_none());@@ -621,7 +621,7 @@ async fn cancel_all_clears_everything() {// Headless (no parent thread) — aborted, but contributes no thread id.let _b = register_test_with_thread("task-all-2", "session-B", None, rq);- let cancelled_threads = cancel_all();+ let cancelled_threads = cancel_all(&crate::core::runtime::DispatchCtx::ambient(), );assert!(cancelled_threads.contains(&"thread-1".to_string()),"cancel_all should report the parent thread of the cancelled sub-agent"@@ -632,15 +632,15 @@ async fn cancel_all_clears_everything() {);assert_eq!(- steer("task-all-1", "session-A", "x".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-all-1", "session-A", "x".into(), QueueLane::Steer).await,Err(SteerError::Unknown));assert_eq!(- steer("task-all-2", "session-B", "x".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-all-2", "session-B", "x".into(), QueueLane::Steer).await,Err(SteerError::Unknown));// Registry is empty now.- assert!(cancel_all().is_empty());+ assert!(cancel_all(&crate::core::runtime::DispatchCtx::ambient(), ).is_empty());}#[tokio::test]@@ -651,7 +651,7 @@ async fn stop_for_thread_aborts_the_threads_running_children() {// Stop button used to leave behind.let child = tokio::spawn(std::future::pending::<()>());let (_tx, rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"task-stop-1".into(),"researcher".into(),"session-stop".into(),@@ -679,11 +679,11 @@ async fn stop_for_thread_aborts_the_threads_running_children() {"stop must abort the detached child task");assert_eq!(- steer("task-stop-1", "session-stop", "x".into(), QueueLane::Steer).await,+ steer(&crate::core::runtime::DispatchCtx::ambient(), "task-stop-1", "session-stop", "x".into(), QueueLane::Steer).await,Err(SteerError::Unknown));assert!(- steer(+ steer(&crate::core::runtime::DispatchCtx::ambient(),"task-stop-other","session-stop","x".into(),diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rsindex bbc85a30a0..fcb1abe144 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents_wire_tests.rs@@ -32,7 +32,7 @@ async fn roster_status_labels_are_literal() {let mut senders = Vec::new();for id in ["wire-run", "wire-done", "wire-await", "wire-fail"] {let (tx, rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),id.into(),"researcher".into(),"wire-parent".into(),@@ -161,7 +161,7 @@ async fn spawn_ledger_record_has_literal_persisted_shape() {let _guard = super::test_guard_async().await;let ws = tempfile::tempdir().unwrap();let (_tx, rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),"wire-shape-1".into(),"researcher".into(),"wire-shape-parent".into(),diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rs b/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rsindex 4779fe5fec..1f0ed0ec44 100644--- a/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/subagent_control_tests.rs@@ -111,7 +111,7 @@ async fn cancel_of_a_finished_run_reports_its_outcome_and_rewrites_nothing() {),] {let (tx, rx) = status_channel();- register(+ register(&crate::core::runtime::DispatchCtx::ambient(),task_id.into(),"agent_memory".into(),"session-rpc".into(),diff --git a/crates/openhuman-core/src/profiles/recovery_tests.rs b/crates/openhuman-core/src/profiles/recovery_tests.rsindex 8c9eac4395..0dac5e49c1 100644--- a/crates/openhuman-core/src/profiles/recovery_tests.rs+++ b/crates/openhuman-core/src/profiles/recovery_tests.rs@@ -16,7 +16,7 @@ fn context_with_store() -> (Arc<CoreContext>, Arc<dyn SessionStoreProvider>) {let provider: Arc<dyn SessionStoreProvider> = Arc::new(tinyagents_session::DriverSessionStores::new(backend).unwrap()- .recover_on_open(&crate::core::runtime::DispatchCtx::ambient(), false),+ .recover_on_open(false),);let mut overrides = crate::agent::host_overrides::HostOverrides::default();overrides.session_store = Some(Arc::clone(&provider));