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
fix(orchestration): cancel each matching subagent job individually
Steven Enamakela5a7c1a339f8
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rsindex fb742987d7..08976ea357 100644--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs@@ -337,21 +337,16 @@ pub(crate) async fn cancel_for_thread(continue;}};- match jobs.cancel_owned(- matching_jobs- .first()- .map(|job| job.id.as_str())- .unwrap_or(task_id.as_str()),- &owner_key,- ) {- Ok(count) => {- cancelled += count;- }- Err(error) => log::warn!(- "[running_subagents] driver thread deletion cancellation failed: {error}"- ),- }for job in matching_jobs {+ match jobs.cancel_owned(job.id.as_str(), &owner_key) {+ Ok(cancelled_job) => {+ cancelled += usize::from(!cancelled_job.status.is_terminal());+ }+ Err(error) => {+ log::warn!("[running_subagents] driver thread deletion cancellation failed: {error}");+ continue;+ }+ }if let Err(error) = jobs.wait_owned(job.id.as_str(), &owner_key).await {log::warn!("[running_subagents] failed waiting for deleted-thread child to settle: {error}");}diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_driver_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_driver_tests.rsindex 002401fd25..5420c72ff0 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_driver_tests.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_driver_tests.rs@@ -405,6 +405,12 @@ async fn deleting_parent_thread_cancels_driver_child_before_discarding_completioArc::new(tinyagents_tasks::InMemoryCompletionStore::new());background_completions::install_store_for_test(&workspace, completion_store);let detached_data = live.data.detached_child();+ let child_cancellation = detached_data.cancellation.clone();+ let cancellation_release = release.clone();+ let release_on_cancel = tokio::spawn(async move {+ child_cancellation.cancelled().await;+ cancellation_release.notify_one();+ });let detached = live.child(tinyagents_harness::context::RunConfig::new("delete-live-driver-child"),@@ -514,7 +520,9 @@ async fn deleting_parent_thread_cancels_driver_child_before_discarding_completiobackground_completions::pending_for(&workspace, thread_id).is_empty(),"queued child completions are discarded after cancellation");- release.notify_waiters();+ release_on_cancel+ .await+ .expect("cancellation-aware child release task completes");}#[tokio::test]diff --git a/crates/openhuman-core/src/threads/ops/crud.rs b/crates/openhuman-core/src/threads/ops/crud.rsindex b214321e39..6d46b2fb3e 100644--- a/crates/openhuman-core/src/threads/ops/crud.rs+++ b/crates/openhuman-core/src/threads/ops/crud.rs@@ -489,8 +489,11 @@ async fn thread_delete_inner(// completion in the gap between the two calls, then discard anything already// queued for delivery. Both target a thread that's being deleted, so there's// nowhere left to deliver to — abort + cleanup is the whole behavior.- let cancelled_legacy =- crate::agent::orchestration::running_subagents::cancel_for_thread(&ctx, &request.thread_id);+ let cancelled_legacy = crate::agent::orchestration::running_subagents::cancel_for_thread(+ &ctx,+ &request.thread_id,+ )+ .await;let jobs = crate::core::runtime::slot_for::<tinyagents_harness_tools::subagents::SubAgentJobRegistry,>(&ctx);