Skip to content

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

refactor(agent): adjust subagent parent handling for headless mode

Steven Enamakel9bbe70940d8c
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
index f20328b424..78426f1439 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs
@@ -6,7 +6,7 @@ impl SpawnSubagentTool {
tool_context: Option<&dyn ToolRunContext>,
run_context: crate::agent::tinyagents::host::OpenHumanRunContext,
detached_parent: Option<
- tinyagents_harness::context::RunContext<
+ &tinyagents_harness::context::RunContext<
crate::agent::tinyagents::host::OpenHumanRunContext,
>,
>,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_surface.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_surface.rs
index 943ac49221..c8088afd33 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_surface.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_surface.rs
@@ -58,12 +58,20 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());
let detached_parent =
crate::agent::subagent_host::detached_subagent_parent(parent, "async-subagent")?;
+ // Headless owners wait for their children before returning, so keep
+ // the actual native root as the driver's parent. Ordinary chat keeps
+ // its detached carrier so background work outlives the turn.
+ let driver_parent = if parent.data.headless_descendant_settlement {
+ parent
+ } else {
+ &detached_parent
+ };
SpawnSubagentTool::new()
.execute_with_live_parent_context(
arguments,
Some(&context),
parent.data.child(),
- detached_parent,
+ driver_parent,
)
.await
}
@@ -329,7 +337,7 @@ impl SpawnSubagentTool {
options,
tool_context,
live_parent.data.child(),
- Some(detached_parent),
+ Some(&detached_parent),
)
.await
}
@@ -339,7 +347,7 @@ impl SpawnSubagentTool {
args: serde_json::Value,
tool_context: Option<&dyn ToolRunContext>,
run_context: crate::agent::tinyagents::host::OpenHumanRunContext,
- detached_parent: RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
+ detached_parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,
) -> anyhow::Result<ToolResult> {
self.execute_with_context_inner(
args,
diff --git a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs
index 20b1aa6ca6..d6a0e4bbbf 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime_session_turn.rs
@@ -63,6 +63,7 @@ impl OpenHumanSessionHost {
None
};
let mut context = OpenHumanRunContext::new().with_host_env(&host_env);
+ context.headless_descendant_settlement = headless;
context.untrusted_input_turn = self.untrusted_input;
context.origin = origin.cloned();
context.approval = approval;