Skip to content

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

fix(orchestration): clone background spawn state before async move

Steven Enamakel53d0e00159d9
diff --git a/crates/openhuman-core/src/agent/orchestration/running_subagents.rs b/crates/openhuman-core/src/agent/orchestration/running_subagents.rs
index 81b2a3beb2..526c6aaf5e 100644
--- a/crates/openhuman-core/src/agent/orchestration/running_subagents.rs
+++ b/crates/openhuman-core/src/agent/orchestration/running_subagents.rs
@@ -70,7 +70,9 @@ pub(crate) use cancel::{
CancelledSubagent, cancel_all, cancel_by_session_in_workspace, cancel_by_task,
cancel_for_thread, stop_for_thread,
};
-pub(crate) use registry::{RegistrationError, admit_spawn, register, status_channel};
+pub(crate) use registry::admit_spawn;
+#[cfg(test)]
+pub(crate) use registry::{RegistrationError, register, status_channel};
pub(crate) use resolve::{resume_ref_for_task_in_workspace, task_id_for_session_in_workspace};
pub(crate) use roster::active_subagents_context_block;
pub use steering::steer;
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
index a515643927..beb16b4f12 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_execute.rs
@@ -387,6 +387,16 @@ impl SpawnAsyncSubagentTool {
let background_store = background_store.clone();
let background_subagent_session_id = background_subagent_session_id.clone();
let background_parent_thread_id = background_parent_thread_id.clone();
+ let background_workspace_dir = background_workspace_dir.clone();
+ let background_dispatch = background_dispatch.clone();
+ let background_agent_id = background_agent_id.clone();
+ let background_task_id = background_task_id.clone();
+ let background_parent_session = background_parent_session.clone();
+ let completion_target = completion_target.clone();
+ let background_worker_thread_id = background_worker_thread_id.clone();
+ let background_store = background_store.clone();
+ let background_subagent_session_id = background_subagent_session_id.clone();
+ let background_parent_thread_id = background_parent_thread_id.clone();
Box::pin(async move {
let finish = async move {
let mut abort_report = AbortReport::arm(
diff --git a/crates/openhuman-core/src/agent/subagent_host/mod.rs b/crates/openhuman-core/src/agent/subagent_host/mod.rs
index 009be9ad01..621f13e8c6 100644
--- a/crates/openhuman-core/src/agent/subagent_host/mod.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/mod.rs
@@ -57,7 +57,9 @@ mod persisted_compat_tests;
// Public API — the entry point and the shapes it returns.
pub use autonomous::{definition_iter_cap, subagent_iter_cap_with_autonomous_lift};
pub(crate) use lifecycle::load_subagent_checkpoint;
-pub(crate) use lifecycle::{run_async_spawn_via_driver_tool, spawn_async_via_driver_tool};
+#[cfg(test)]
+pub(crate) use lifecycle::run_async_spawn_via_driver_tool;
+pub(crate) use lifecycle::spawn_async_via_driver_tool;
pub use lifecycle::{
continue_subagent, continue_subagent_with_parent, run_subagent, run_subagent_with_parent,
OpenHumanSubagentHost,