Skip to content

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

fix(orchestration): skip terminal jobs when cancelling a thread

Steven Enamakel111ef5368c62
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 9d7cc5aebc..0ce2bbccf4 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents/cancel.rs
@@ -344,7 +344,11 @@ pub(crate) async fn cancel_for_thread(
));
continue;
}
- for job in matching_jobs {
+ let live_jobs = matching_jobs
+ .into_iter()
+ .filter(|job| !job.status.is_terminal())
+ .collect::<Vec<_>>();
+ for job in live_jobs {
match jobs.cancel_owned(job.id.as_str(), &owner_key) {
Ok(cancelled_job) => {
cancelled += usize::from(!cancelled_job.status.is_terminal());
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.rs
index c062e8f381..68f5204b28 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
@@ -594,7 +594,7 @@ async fn thread_delete_keeps_completions_when_driver_task_scope_cannot_be_resolv
&dispatch,
&workspace,
parent_session,
- "stale-driver-task".into(),
+ "stale-driver-task",
"task_manager_agent",
"queued child result",
Some(thread_id.into()),