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): scope e2e subagent tests under core context
Steven Enamakelba6ba88a3ca5
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rsindex bb45181781..7b0d4faeb7 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_continuation_tests.rs@@ -38,6 +38,7 @@ async fn spawn_subagent_with_same_task_key_resumes_paused_job_through_shared_dri"continue-paused-e2e","continue-paused-e2e-thread",);+ crate::core::runtime::CoreContext::scope(Arc::clone(&_core), async {assert!(live.data.dispatch_ctx().resolved().is_some(),"the parent carrier retains its core context"@@ -366,6 +367,8 @@ async fn spawn_subagent_with_same_task_key_resumes_paused_job_through_shared_driSome(&original_lifecycle_key),"resume preserves the original lifecycle identity");+ })+ .await;}#[tokio::test]diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rsindex ceb8e68583..9391eda80e 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_control_tests.rs@@ -64,21 +64,22 @@ async fn unscoped_web_stop_cancels_a_running_driver_subagent() {.with_thread(thread_id),host,);- let detached = crate::agent::subagent_host::detached_subagent_parent(&live, "stop-child")- .expect("detached parent");let accepted = crate::core::runtime::CoreContext::scope(Arc::clone(&core),- Box::pin(SpawnSubagentTool::new().execute_with_live_parent_context(- json!({- "agent_id": "task_manager_agent",- "prompt": "wait for the thread stop",- "model": "test-model",- "task_key": "stop detached child"- }),- None,- live.data.child(),- detached.clone(),- )),+ Box::pin(+ SpawnSubagentTool::new().execute_with_live_parent_context(+ json!({+ "agent_id": "task_manager_agent",+ "prompt": "wait for the thread stop",+ "model": "test-model",+ "task_key": "stop detached child"+ }),+ None,+ live.data.child(),+ crate::agent::subagent_host::detached_subagent_parent(&live, "stop-child")+ .expect("detached parent"),+ ),+ ),).await.expect("spawn child");@@ -91,11 +92,6 @@ async fn unscoped_web_stop_cancels_a_running_driver_subagent() {.and_then(|value| serde_json::from_str::<serde_json::Value>(value).ok()).and_then(|value| value["task_id"].as_str().map(str::to_owned)).expect("accepted child includes its task ID");- let lifecycle_key = tinyagents_orchestration::subagent::SubagentTaskKey::from_context(- &detached,- task_id.clone(),- None,- );tokio::time::timeout(std::time::Duration::from_secs(5), started_rx.recv()).await.expect("driver child reached provider gate")@@ -108,6 +104,21 @@ async fn unscoped_web_stop_cancels_a_running_driver_subagent() {let jobs = crate::core::runtime::slot_for::<tinyagents_harness_tools::subagents::SubAgentJobRegistry,>(&dispatch);+ let store = crate::agent::orchestration::subagent_sessions::SubagentSessionStore::new(+ workspace.path().to_path_buf(),+ );+ let before_scoped =+ crate::core::runtime::CoreContext::sync_scope(Arc::clone(&core), || store.load())+ .expect("load live durable row");+ let row_before = before_scoped+ .iter()+ .find(|row| row.current_task_id.as_deref() == Some(task_id.as_str()))+ .expect("driver persistence includes the live child");+ assert_eq!(row_before.parent_thread_id.as_deref(), Some(thread_id));+ let lifecycle_key = row_before+ .lifecycle_key+ .clone()+ .expect("persisted child row carries its lifecycle key");let owner = crate::agent::tinyagents::tool_registration::subagent_owner_key(workspace.path(),"stop-detached-subagent-session",@@ -123,12 +134,6 @@ async fn unscoped_web_stop_cancels_a_running_driver_subagent() {job.status,tinyagents_orchestration::subagent::SubAgentJobStatus::Running);- let store = crate::agent::orchestration::subagent_sessions::SubagentSessionStore::new(- workspace.path().to_path_buf(),- );- let before_scoped =- crate::core::runtime::CoreContext::sync_scope(Arc::clone(&core), || store.load())- .expect("load live durable row");assert!(before_scoped.iter().any(|row| {row.current_task_id.as_deref() == Some(task_id.as_str())diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rsindex 85eaada331..f1e4006e31 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_profile_cancel_tests.rs@@ -125,7 +125,7 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {}),None,live.data.child(),- detached.clone(),+ detached,),).await@@ -139,11 +139,6 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {.and_then(|value| serde_json::from_str::<serde_json::Value>(value).ok()).and_then(|value| value["task_id"].as_str().map(str::to_owned)).expect("accepted child includes public task ID");- let lifecycle_key = tinyagents_orchestration::subagent::SubagentTaskKey::from_context(- &detached,- task_id.clone(),- None,- );tokio::time::timeout(std::time::Duration::from_secs(5), started_rx.recv()).await.expect("child reached the scripted provider gate")@@ -152,6 +147,19 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {let alice_jobs = crate::core::runtime::slot_for::<tinyagents_harness_tools::subagents::SubAgentJobRegistry,>(&alice_ctx);+ let store = SubagentSessionStore::new(workspace.clone());+ let row_before = CoreContext::sync_scope(Arc::clone(&alice), || store.load())+ .expect("durable child row readable")+ .into_iter()+ .find(|row| row.current_task_id.as_deref() == Some(task_id.as_str()))+ .expect("durable row belongs to the live child");+ assert_eq!(row_before.status, DurableSubagentStatus::Running);+ assert_eq!(row_before.parent_session, "shared-profile-parent-session");+ assert_eq!(row_before.parent_thread_id.as_deref(), Some(thread_id));+ let lifecycle_key = row_before+ .lifecycle_key+ .clone()+ .expect("persisted child row carries its lifecycle key");let alice_owner = crate::agent::tinyagents::tool_registration::subagent_owner_key(&workspace,"shared-profile-parent-session",@@ -165,16 +173,6 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {.expect("real child is registered in Alice's scoped driver registry");assert_eq!(alice_job.status, SubAgentJobStatus::Running);- let store = SubagentSessionStore::new(workspace.clone());- let row_before = CoreContext::sync_scope(Arc::clone(&alice), || store.load())- .expect("durable child row readable")- .into_iter()- .find(|row| row.current_task_id.as_deref() == Some(task_id.as_str()))- .expect("durable row belongs to the live child");- assert_eq!(row_before.status, DurableSubagentStatus::Running);- assert_eq!(row_before.parent_session, "shared-profile-parent-session");- assert_eq!(row_before.parent_thread_id.as_deref(), Some(thread_id));-let bob_ctx = DispatchCtx::new(Arc::clone(&bob));let bob_job_registry = crate::core::runtime::slot_for::<tinyagents_harness_tools::subagents::SubAgentJobRegistry,