Skip to content

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

fix(subagent): settle paused driver jobs on cancel

Steven Enamakel624585d10c36
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs
index 6dc9e2c7a3..0bd9df8071 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/mod.rs
@@ -6,6 +6,7 @@ mod types;
pub use ops::{
action_root_key, cancel_driver_job_by_task, cancel_driver_job_for_observed_session,
+ cancel_driver_job_for_session,
cancel_driver_jobs_for_thread, close_if_current, find_reusable, list_for_parent,
mark_driver_pause_cancelled, mark_failed, mark_finished, normalize_task_key,
resolve_lifecycle_key, reuse_decision, task_title_from_prompt, upsert_running,
diff --git a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs
index c8d2e43a19..16b432ac0c 100644
--- a/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs
+++ b/crates/openhuman-core/src/agent/orchestration/subagent_sessions/ops_driver.rs
@@ -250,7 +250,11 @@ pub fn cancel_driver_job_by_task(
};
let already_finished = match session.status {
DurableSubagentStatus::Idle => {
- Some(tinyagents_orchestration::subagent::FinishedOutcome::Completed)
+ let finished = typed_finished()?;
+ if finished.is_none() {
+ return Ok(None);
+ }
+ finished
}
DurableSubagentStatus::Failed => match typed_finished()? {
Some(finished) => Some(finished),
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs
index 027294529f..de81145a7c 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/tools_e2e_workspace_owner_tests.rs
@@ -393,7 +393,7 @@ async fn driver_job_controls_are_isolated_by_workspace_with_shared_runtime_state
)),
Err(error) => assert_eq!(
error.to_string(),
- "tinyagents harness run failed: run cancelled"
+ "provider call failed: tinyagents harness run failed: run cancelled"
),
}
assert_eq!(
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs
index 7fc01d2f26..6de8bbb3ae 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle/driver_result.rs
@@ -38,9 +38,6 @@ pub(crate) async fn resolve_inline_driver_outcome(
.lock()
.unwrap_or_else(|poisoned| poisoned.into_inner())
.remove(task_key);
- if let Some(cached) = cached.clone() {
- return Ok((cached, public_job_id));
- }
// The driver's persistence CAS result is authoritative. Another
// invocation can win terminal/pause persistence while this executor's
diff --git a/crates/openhuman-core/src/agent_runs/subagent_control.rs b/crates/openhuman-core/src/agent_runs/subagent_control.rs
index bc1291e0c1..311144f780 100644
--- a/crates/openhuman-core/src/agent_runs/subagent_control.rs
+++ b/crates/openhuman-core/src/agent_runs/subagent_control.rs
@@ -159,6 +159,9 @@ fn handle_subagent_cancel(ctx: DispatchCtx, params: Map<String, Value>) -> Contr
// Active driver jobs finish through the awaited host hook.
// A paused job has already returned from that hook, so this
// handler settles and reports that one terminal transition.
+ if let Some(paused) = meta.driver_pause.as_ref() {
+ settle_paused_driver_cancel(&ctx, paused, reason.as_deref()).await?;
+ }
(true, None)
} else {
let summary = match reason.as_deref().map(str::trim).filter(|r| !r.is_empty()) {