Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(orchestration): skip subagent cancellation for threads without driver tasks

Steven Enamakelc2c04037ad11
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
index 2df7180f3a..8d00b01819 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
@@ -526,11 +526,21 @@ pub(crate) fn stop_for_thread(
/// tombstones the parent completion queues.
pub(crate) async fn cancel_all(
ctx: &crate::core::runtime::DispatchCtx,
+ workspace_dir: &Path,
thread_ids: &[String],
) -> Result<Vec<String>, String> {
let mut cancelled_threads = Vec::new();
let mut failures = Vec::new();
for thread_id in thread_ids {
+ if crate::agent::orchestration::completion_owners::driver_tasks_for_thread(
+ ctx,
+ workspace_dir,
+ thread_id,
+ )
+ .is_empty()
+ {
+ continue;
+ }
match cancel_for_thread(ctx, thread_id).await {
Ok(count) if count > 0 => cancelled_threads.push(thread_id.clone()),
Ok(_) => {}
diff --git a/crates/openhuman-core/src/threads/ops/purge.rs b/crates/openhuman-core/src/threads/ops/purge.rs
index da6725a6f0..619d0ee86c 100644
--- a/crates/openhuman-core/src/threads/ops/purge.rs
+++ b/crates/openhuman-core/src/threads/ops/purge.rs
@@ -63,7 +63,7 @@ async fn threads_purge_inner(
// driver jobs, then durably tombstone each parent before the final queue
// wipe so a late result cannot be delivered after purge returns.
use crate::agent::orchestration::{background_completions, running_subagents};
- let cancellation = running_subagents::cancel_all(&ctx, &thread_ids).await;
+ let cancellation = running_subagents::cancel_all(&ctx, &dir, &thread_ids).await;
let cancelled_threads = cancellation.as_ref().map_or(0, Vec::len);
let mut discarded = 0;
let mut cleanup_failures = Vec::new();