Skip to content

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

fix(subagent_host): surface driver spawn failures and require structured job refs

Steven Enamakel12ae63332628
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
index bd06f06ed4..3ceae619ed 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs
@@ -190,12 +190,29 @@ pub(crate) async fn run_async_spawn_via_driver_tool(
)
.await
.map_err(|error| SubagentRunError::Provider(anyhow::anyhow!(error.to_string())))?;
- let rendered_result = tool_result.output();
- let reply: serde_json::Value = serde_json::from_str(&rendered_result).map_err(|error| {
- SubagentRunError::Provider(anyhow::anyhow!(format!(
- "driver-backed async spawn returned an invalid job reference: {error}; result={rendered_result}"
- )))
- })?;
+ if tool_result.is_error {
+ if let Some(error) = bundle
+ .failures
+ .lock()
+ .unwrap_or_else(|poisoned| poisoned.into_inner())
+ .remove(&task_key)
+ {
+ return Err(error);
+ }
+ return Err(SubagentRunError::Provider(anyhow::anyhow!(format!(
+ "driver-backed async spawn failed: {}",
+ tool_result.output()
+ ))));
+ }
+ let reply = match tool_result.content.first() {
+ Some(tinytools::ToolContent::Json { data }) => data.clone(),
+ _ => {
+ return Err(SubagentRunError::Provider(anyhow::anyhow!(format!(
+ "driver-backed async spawn returned no structured job reference: {}",
+ tool_result.output()
+ ))));
+ }
+ };
let public_job_id = reply
.get("task_id")
.and_then(serde_json::Value::as_str)
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 dcf14a5cfa..85a2389a70 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
@@ -51,9 +51,15 @@ async fn runner_rejects_spawn_beyond_max_depth() {
#[tokio::test]
async fn prepared_async_spawn_runs_through_driver_jobs_dispatcher() {
+ let scratch = tempfile::tempdir().expect("isolated async spawn fixture");
+ let workspace = scratch.path().join("workspace");
+ std::fs::create_dir_all(&workspace).expect("create isolated workspace");
let provider = ScriptedProvider::new(vec![text_response("driver result")]);
- let mut options = with_parent(make_parent(provider, vec![]), SubagentRunOptions::default());
+ 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(
tinyagents_harness::context::RunConfig::new("driver-spawn-parent")
@@ -72,6 +78,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_eq!(provider.captured.lock().len(), 1, "child provider must run");
let jobs = crate::core::runtime::slot_for::<
tinyagents_orchestration::subagent::SubAgentJobRegistry,
>(&parent.data.dispatch_ctx());