Skip to content

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

fix(subagent_host): retain generated task id and emit effects on spawn errors

Steven Enamakel37c1109b8bbd
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index ba7a03dc36..a9309292ee 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -109,6 +109,8 @@ pub(crate) async fn run_async_spawn_via_driver_tool(
.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.clone(), None);
let (tool_result, bundle) = invoke_async_spawn_driver_tool(
parent,
@@ -162,6 +164,8 @@ pub(crate) async fn spawn_async_via_driver_tool(
.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 (tool_result, bundle) = invoke_async_spawn_driver_tool(
parent,
@@ -302,9 +306,10 @@ async fn invoke_async_spawn_driver_tool(
Err(host_error.unwrap_or(error))
}
};
- let emit_effects = projected.as_ref().is_ok_and(|outcome| {
- outcome.persistence_disposition.should_emit_host_effects()
- });
+ let emit_effects = match &projected {
+ Ok(outcome) => outcome.persistence_disposition.should_emit_host_effects(),
+ Err(_) => true,
+ };
completion(target, projected, emit_effects).await;
})
});
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs b/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs
index 85a2389a70..42db94d63f 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops_tests_model_resolution_tests.rs
@@ -58,7 +58,6 @@ async fn prepared_async_spawn_runs_through_driver_jobs_dispatcher() {
let mut parent_context = make_parent(provider.clone(), vec![]);
parent_context.workspace_dir = workspace;
let mut options = with_parent(parent_context, SubagentRunOptions::default());
- options.task_id = Some("driver-backed-async-spawn".into());
options.checkpoint_dir = Some(scratch.path().join("checkpoints"));
options.run_context.thread_id = Some("driver-spawn-thread".into());
let parent = options.run_context.clone().into_tinyagents(
@@ -77,7 +76,7 @@ async fn prepared_async_spawn_runs_through_driver_jobs_dispatcher() {
assert!(matches!(outcome.status, SubagentRunStatus::Completed));
assert_eq!(outcome.output, "driver result");
- assert_eq!(outcome.task_id, "driver-backed-async-spawn");
+ assert!(!outcome.task_id.is_empty(), "host must retain generated task ID");
assert_eq!(provider.captured.lock().len(), 1, "child provider must run");
let jobs = crate::core::runtime::slot_for::<
tinyagents_orchestration::subagent::SubAgentJobRegistry,