Skip to content

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

fix(orchestration): await driver session close and fall back to driver cancel reason

Steven Enamakel8f23b2401f83
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs
index 5251b3fd45..ac48db4727 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_completion.rs
@@ -266,7 +266,13 @@ pub(super) fn make_completion(
session.current_task_id.as_deref()
== Some(outcome.task_id.as_str())
})
- .and_then(|session| session.latest_error),
+ .and_then(|session| session.latest_error)
+ .or_else(|| {
+ crate::agent::orchestration::completion_owners::take_driver_cancel_reason(
+ &background_dispatch,
+ &outcome.task_id,
+ )
+ }),
Err(error) => {
log::warn!(
"[subagent_reuse] cancellation reason lookup failed subagent_session_id={} task_id={} error={error}",
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rs
index 12d4e5785c..7f4a5b710c 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_driver_lookup.rs
@@ -106,7 +106,8 @@ async fn close_reusable_driver_session(
&session.subagent_session_id,
parent_session,
workspace_dir,
- );
+ )
+ .await;
}
let (Some(task_id), Some(lifecycle_key)) = (
session.current_task_id.as_deref(),
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.rs
index 7a39cd7d54..b508bf58e1 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
@@ -191,6 +191,7 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {
Some(&workspace),
Some("foreign profile cancellation"),
)
+ .await
})
.await
.expect("foreign profile cancellation lookup");
@@ -232,6 +233,7 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {
None,
None,
)
+ .await
.expect("unbound SaaS control refusal")
.is_none(),
"SaaS cancellation without a profile fails closed"
@@ -265,6 +267,7 @@ async fn profile_scope_cannot_cancel_another_profiles_driver_child() {
Some(&workspace),
Some("owner requested stop"),
)
+ .await
})
.await
.expect("owner cancellation lookup");