Skip to content

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

refactor(subagent_host): make subagent completion callback async

Steven Enamakelbd3db688391e
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index 92e0fb3c41..99d7a6cb35 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -8,7 +8,9 @@
use std::{
collections::HashMap,
fs::OpenOptions,
+ future::Future,
path::PathBuf,
+ pin::Pin,
sync::{Arc, Mutex},
};
@@ -147,7 +149,13 @@ pub(crate) async fn spawn_async_via_driver_tool(
definition: crate::agent_registry::host_definition::AgentDefinition,
input: String,
options: SubagentRunOptions,
- completion: impl Fn(&str, Result<SubagentRunOutcome, String>) + Send + Sync + 'static,
+ completion: impl Fn(
+ String,
+ Result<SubagentRunOutcome, String>,
+ ) -> Pin<Box<dyn Future<Output = ()> + Send>>
+ + Send
+ + Sync
+ + 'static,
) -> Result<String, SubagentRunError> {
let task_id = options
.task_id
@@ -166,7 +174,11 @@ pub(crate) async fn spawn_async_via_driver_tool(
decode_driver_job_result(tool_result, &bundle, &task_key)
}
-type HostCompletion = Arc<dyn Fn(&str, Result<SubagentRunOutcome, String>) + Send + Sync>;
+type HostCompletion = Arc<
+ dyn Fn(String, Result<SubagentRunOutcome, String>) -> Pin<Box<dyn Future<Output = ()> + Send>>
+ + Send
+ + Sync,
+>;
async fn invoke_async_spawn_driver_tool(
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
@@ -276,7 +288,7 @@ async fn invoke_async_spawn_driver_tool(
Err(host_error.unwrap_or(error))
}
};
- completion(&target, projected);
+ completion(target, projected).await;
})
});
}
diff --git a/vendor/tinyagents b/vendor/tinyagents
index d7464c8f4a..8712b1e483 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit d7464c8f4a5863dd0cb8c34c57fb45ad113208c0
+Subproject commit 8712b1e48383f01e9b3e5fac61b1f2a65df91ad1