Skip to content

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

fix(agent): refuse duplicate subagent spawn when steering fails

Steven Enamakelab23b5013b9f
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_host_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_host_impl.rs
index 54afd0d725..a2fc479f30 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_host_impl.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_host_impl.rs
@@ -248,6 +248,10 @@ impl SpawnAsyncSubagentTool {
definition.id,
err
);
+ return Ok(ToolResult::error(format!(
+ "spawn_async_subagent: failed to continue existing running task '{}' in session '{}'; refusing to start a duplicate: {err}",
+ running_task_id, session.subagent_session_id
+ )));
}
}
}
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 c843cdd9cd..8da3c6512a 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
@@ -78,6 +78,10 @@ async fn failed_steer_of_running_reused_session_does_not_create_second_child() {
)
.expect("detached child context")
.with_cancellation(detached_data.cancellation.clone());
+ let jobs = crate::core::runtime::slot_for::<
+ tinyagents_harness_tools::subagents::SubAgentJobRegistry,
+ >(&live.data.dispatch_ctx());
+ let jobs_before = jobs.list().len();
let result = crate::agent::orchestration::tools::SpawnAsyncSubagentTool::new()
.execute_with_live_parent_context(
json!({
@@ -94,7 +98,14 @@ async fn failed_steer_of_running_reused_session_does_not_create_second_child() {
.expect("spawn tool executes");
assert!(result.is_error, "failed steer must be reported, got: {}", result.output());
+ assert!(
+ result.output().contains("refusing to start a duplicate")
+ && result.output().contains("existing-running-task"),
+ "the refusal identifies the failed reusable task: {}",
+ result.output()
+ );
assert!(provider.seen.lock().is_empty(), "no second child model run may start");
+ assert_eq!(jobs.list().len(), jobs_before, "no second child job is admitted");
let after = store
.load()
.expect("session store remains readable")