Skip to content

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

feat(subagent_host): resume clarification checkpoints via detached jobs

Steven Enamakeld541219180db
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index 9f45ed7f92..b4b0b41ba2 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -203,10 +203,40 @@ pub(crate) async fn spawn_async_via_driver_tool(
+ Sync
+ 'static,
) -> Result<String, SubagentRunError> {
- spawn_async_via_driver_tool_using_jobs(parent, definition, input, options, None, completion)
+ spawn_async_via_driver_tool_using_jobs(parent, definition, input, options, None, None, completion)
.await
}
+/// Resumes a host-authorized clarification checkpoint through the same
+/// detached Jobs path as a new spawn, retaining its lifecycle key and task id.
+pub(crate) async fn resume_async_via_driver_tool(
+ parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
+ original_key: SubagentTaskKey,
+ resume: SubagentResume,
+ definition: crate::agent_registry::host_definition::AgentDefinition,
+ input: String,
+ options: SubagentRunOptions,
+ completion: impl Fn(
+ String,
+ Result<SubagentRunOutcome, String>,
+ bool,
+ ) -> Pin<Box<dyn Future<Output = ()> + Send>>
+ + Send
+ + Sync
+ + 'static,
+) -> Result<String, SubagentRunError> {
+ spawn_async_via_driver_tool_using_jobs(
+ parent,
+ definition,
+ input,
+ options,
+ None,
+ Some((original_key, resume)),
+ completion,
+ )
+ .await
+}
+
#[cfg(test)]
pub(crate) async fn spawn_async_via_driver_tool_with_jobs(
parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
@@ -229,6 +259,7 @@ pub(crate) async fn spawn_async_via_driver_tool_with_jobs(
input,
options,
Some(jobs),
+ None,
completion,
)
.await
@@ -240,6 +271,7 @@ async fn spawn_async_via_driver_tool_using_jobs(
input: String,
options: SubagentRunOptions,
jobs: Option<tinyagents_harness_tools::subagents::SubAgentJobRegistry>,
+ continuation: Option<(SubagentTaskKey, SubagentResume)>,
completion: impl Fn(
String,
Result<SubagentRunOutcome, String>,
@@ -249,13 +281,17 @@ async fn spawn_async_via_driver_tool_using_jobs(
+ Sync
+ 'static,
) -> Result<String, SubagentRunError> {
- let task_id = options
- .task_id
- .clone()
+ let task_id = continuation
+ .as_ref()
+ .map(|(key, _)| key.task_id.clone())
+ .or_else(|| options.task_id.clone())
.unwrap_or_else(|| format!("sub-{}", uuid::Uuid::new_v4()));
let mut options = options;
options.task_id = Some(task_id.clone());
- let task_key = SubagentTaskKey::from_context(parent, task_id, None);
+ let task_key = continuation
+ .as_ref()
+ .map(|(key, _)| key.clone())
+ .unwrap_or_else(|| SubagentTaskKey::from_context(parent, task_id.clone(), None));
let (tool_result, bundle) = invoke_async_spawn_driver_tool(
parent,
definition,
@@ -264,7 +300,7 @@ async fn spawn_async_via_driver_tool_using_jobs(
"background",
Some(Arc::new(completion)),
jobs,
- None,
+ continuation,
)
.await?;
decode_driver_job_result(tool_result, &bundle, &task_key)