The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(subagent): extract detached parent construction into shared helper
Steven Enamakela29b75c7085d
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent_host.rs b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent_host.rsindex 170e49a4f5..5ca7bb95e2 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent_host.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/continue_subagent_host.rs@@ -155,18 +155,10 @@ impl ContinueSubagentTool {serde_json::Value::String(model.clone()),);}- let detached_data = live_parent.data.detached_child();- let detached_cancellation = detached_data.cancellation.clone();- let detached_parent = live_parent- .child(- tinyagents_harness::context::RunConfig::new(format!(- "async-subagent-{}",- uuid::Uuid::new_v4()- )),- detached_data,- )- .map_err(|error| anyhow::anyhow!(error.to_string()))?- .with_cancellation(detached_cancellation);+ let detached_parent = crate::agent::subagent_host::detached_subagent_parent(+ live_parent,+ "async-subagent",+ )?;super::spawn_async_subagent::SpawnAsyncSubagentTool::new().execute_with_live_parent_context(async_args,diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_surface.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_surface.rsindex e5cd58fd72..7d2cca9354 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_surface.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_async_subagent_surface.rs@@ -61,15 +61,10 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,) -> anyhow::Result<ToolResult> {let context = ToolExecutionContext::from_run_context(parent, _call_id.clone());- let detached_data = parent.data.detached_child();- let detached_cancellation = detached_data.cancellation.clone();- let detached_parent = parent- .child(- RunConfig::new(format!("async-subagent-{}", uuid::Uuid::new_v4())),- detached_data,- )- .map_err(|error| anyhow::anyhow!(error.to_string()))?- .with_cancellation(detached_cancellation);+ let detached_parent = crate::agent::subagent_host::detached_subagent_parent(+ parent,+ "async-subagent",+ )?;SpawnAsyncSubagentTool::new().execute_with_live_parent_context(arguments,@@ -329,15 +324,10 @@ impl SpawnAsyncSubagentTool {parent: crate::agent::harness::ParentExecutionContext,) -> anyhow::Result<ToolResult> {let live_parent = super::live_parent_run_context("direct-async-subagent", parent);- let detached_data = live_parent.data.detached_child();- let detached_cancellation = detached_data.cancellation.clone();- let detached_parent = live_parent- .child(- RunConfig::new(format!("async-subagent-{}", uuid::Uuid::new_v4())),- detached_data,- )- .map_err(|error| anyhow::anyhow!(error.to_string()))?- .with_cancellation(detached_cancellation);+ let detached_parent = crate::agent::subagent_host::detached_subagent_parent(+ &live_parent,+ "async-subagent",+ )?;self.execute_with_context_inner(args,options,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.rsindex 3b6e014c4c..e54a1a214a 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@@ -220,18 +220,10 @@ impl SpawnSubagentTool {agent_id = %definition.id,"[spawn_subagent] routing to reusable async sub-agent by default");- let detached_data = live_parent.data.detached_child();- let detached_cancellation = detached_data.cancellation.clone();- let detached_parent = live_parent- .child(- tinyagents_harness::context::RunConfig::new(format!(- "async-subagent-{}",- uuid::Uuid::new_v4()- )),- detached_data,- )- .map_err(|error| anyhow::anyhow!(error.to_string()))?- .with_cancellation(detached_cancellation);+ let detached_parent = crate::agent::subagent_host::detached_subagent_parent(+ live_parent,+ "async-subagent",+ )?;return super::spawn_async_subagent::SpawnAsyncSubagentTool::new().execute_with_live_parent_context(async_args,diff --git a/crates/openhuman-core/src/agent/orchestration/tools/subagent_dispatch_host.rs b/crates/openhuman-core/src/agent/orchestration/tools/subagent_dispatch_host.rsindex 86c897890e..faadca0616 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/subagent_dispatch_host.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/subagent_dispatch_host.rs@@ -297,15 +297,11 @@ pub(crate) async fn dispatch_subagent_with_live_parent(// agent-turn futures) overflows the test-thread stack on deep// parallel-delegation flows.return Box::pin(async move {- let detached_data = live_parent.data.detached_child();- let detached_cancellation = detached_data.cancellation.clone();- let detached_parent = live_parent- .child(- RunConfig::new(format!("async-subagent-{}", uuid::Uuid::new_v4())),- detached_data,- )- .map_err(|error| anyhow::anyhow!(error.to_string()))?- .with_cancellation(detached_cancellation);+ let detached_parent =+ crate::agent::subagent_host::detached_subagent_parent(+ live_parent,+ "async-subagent",+ )?;super::spawn_async_subagent::SpawnAsyncSubagentTool::new().execute_with_live_parent_context(async_args,diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rsindex d1c36f1ef7..1e9b0a709b 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs@@ -37,6 +37,22 @@ use super::{SubagentRunError, SubagentRunOptions, SubagentRunOutcome, SubagentRunStatus, SubagentUsage,};+/// Creates the detached child carrier used by OpenHuman's async delegation+/// adapters while preserving the authenticated parent lineage and detached+/// cancellation token for TinyAgents' driver.+pub(crate) fn detached_subagent_parent(+ parent: &RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>,+ run_name: &str,+) -> anyhow::Result<RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>> {+ let data = parent.data.detached_child();+ let cancellation = data.cancellation.clone();+ let config = RunConfig::new(format!("{run_name}-{}", uuid::Uuid::new_v4()));+ parent+ .child(config, data)+ .map(|context| context.with_cancellation(cancellation))+ .map_err(|error| anyhow::anyhow!(error.to_string()))+}+/// Runs one host subagent through a neutral driver using a real direct child.////// Callers that are already inside a TinyAgents turn must use this entrypoint:diff --git a/crates/openhuman-core/src/agent/subagent_host/mod.rs b/crates/openhuman-core/src/agent/subagent_host/mod.rsindex deba91837d..ec21ccb3e1 100644--- a/crates/openhuman-core/src/agent/subagent_host/mod.rs+++ b/crates/openhuman-core/src/agent/subagent_host/mod.rs@@ -57,6 +57,7 @@ mod persisted_compat_tests;// Public API — the entry point and the shapes it returns.pub use autonomous::{definition_iter_cap, subagent_iter_cap_with_autonomous_lift};pub(crate) use lifecycle::load_subagent_checkpoint;+pub(crate) use lifecycle::detached_subagent_parent;pub(crate) use lifecycle::run_configured_delegate_via_driver_tool;pub(crate) use lifecycle::run_subagent_via_driver_tool;pub(crate) use lifecycle::spawn_async_via_driver_tool;