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
fix(subagent): preserve parent workspace when spawning detached subagents
Steven Enamakelbf7294eaf1c1
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 131476a074..44eff1358f 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@@ -83,9 +83,6 @@ impl SpawnSubagentTool {let task_workspace = workspace_descriptor.clone().unwrap_or_else(|| tinytools::WorkspaceDescriptor::new(parent.workspace_dir.clone()));- let detached_parent_with_workspace = (*detached_parent)- .clone()- .with_workspace(task_workspace.clone());let resolved_model = definition.model.resolve(parent.model_name.as_str());let target_model = model_override.as_deref().unwrap_or(&resolved_model);if crate::attachments::should_forward_parent_images(&prompt)@@ -342,7 +339,7 @@ impl SpawnSubagentTool {let completion = completion::make_completion(dispatch.clone().into_core(),- detached_parent_with_workspace.data.origin.clone(),+ detached_parent.data.origin.clone(),progress_sink.clone(),parent.workspace_dir.clone(),dispatch.clone(),@@ -367,7 +364,7 @@ impl SpawnSubagentTool {.clone().unwrap_or_else(|| resumed_session.subagent_session_id.clone()),),- run_context: detached_parent_with_workspace.data.child(),+ run_context: detached_parent.data.child(),worker_thread_id: session.worker_thread_id.clone(),initial_history: None,checkpoint_dir: Some(checkpoint_dir),@@ -376,7 +373,7 @@ impl SpawnSubagentTool {message_run_queue: None,};if let Err(error) = crate::agent::subagent_host::resume_async_via_driver_tool(- &detached_parent_with_workspace,+ detached_parent,original_key,checkpoint_resume,definition.clone(),@@ -431,7 +428,7 @@ impl SpawnSubagentTool {if session.status == DurableSubagentStatus::Running {if let Some(ref running_task_id) = session.current_task_id {match steer_reusable_session(- &detached_parent_with_workspace,+ detached_parent,&session.subagent_session_id,follow_up_prompt.clone(),)@@ -555,7 +552,7 @@ impl SpawnSubagentTool {task_id: task_id.clone(),lifecycle_key: Some(tinyagents_orchestration::subagent::SubagentTaskKey::from_context(- &detached_parent_with_workspace,+ detached_parent,task_id.clone(),parent_thread_id.clone(),),@@ -664,7 +661,7 @@ impl SpawnSubagentTool {background_parent_thread_id.as_deref().unwrap_or("none"));let completion_core = dispatch.clone().into_core();- let completion_origin = detached_parent_with_workspace.data.origin.clone();+ let completion_origin = detached_parent.data.origin.clone();let completion_worker_thread_id = background_worker_thread_id.clone();let registration_progress = progress_sink.clone();let registration_completion_target = completion_target.clone();@@ -694,7 +691,7 @@ impl SpawnSubagentTool {model_override,task_id: Some(task_id.clone()),thread_id: Some(background_thread_id),- run_context: detached_parent_with_workspace.data.child(),+ run_context: detached_parent.data.child(),worker_thread_id: background_worker_thread_id,initial_history,checkpoint_dir: None,@@ -703,7 +700,7 @@ impl SpawnSubagentTool {message_run_queue: None,};if let Err(error) = crate::agent::subagent_host::spawn_async_via_driver_tool(- &detached_parent_with_workspace,+ detached_parent,definition.clone(),background_prompt,options,diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rsindex 52357e63c7..7828ff19bf 100644--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle.rs@@ -26,8 +26,8 @@ mod checkpoint;#[path = "lifecycle_outcome.rs"]mod outcome;use checkpoint::absolute_checkpoint_dir;-pub(super) use driver_adapter::outcome_to_host;use driver_adapter::HostInvocation;+pub(super) use driver_adapter::outcome_to_host;#[path = "lifecycle/driver_result.rs"]mod driver_result;@@ -47,10 +47,29 @@ pub(crate) fn detached_subagent_parent() -> anyhow::Result<RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>> {let data = parent.data.detached_child();let cancellation = data.cancellation.clone();+ let workspace = parent+ .workspace()+ .cloned()+ .or_else(|| {+ data.parent+ .as_ref()+ .and_then(|context| context.workspace_descriptor.clone())+ })+ .or_else(|| {+ data.parent+ .as_ref()+ .map(|context| tinytools::WorkspaceDescriptor::new(context.workspace_dir.clone()))+ });let config = RunConfig::new(format!("{run_name}-{}", uuid::Uuid::new_v4()));parent.child(config, data)- .map(|context| context.with_cancellation(cancellation))+ .map(|context| {+ let context = context.with_cancellation(cancellation);+ match workspace {+ Some(workspace) => context.with_workspace(workspace),+ None => context,+ }+ }).map_err(|error| anyhow::anyhow!(error.to_string()))}@@ -84,13 +103,13 @@ pub(crate) async fn spawn_async_via_driver_tool(input: String,options: SubagentRunOptions,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ 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, None, completion,@@ -108,13 +127,13 @@ pub(crate) async fn resume_async_via_driver_tool(input: String,options: SubagentRunOptions,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ 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,@@ -136,13 +155,13 @@ pub(crate) async fn spawn_async_via_driver_tool_with_jobs(options: SubagentRunOptions,jobs: tinyagents_harness_tools::subagents::SubAgentJobRegistry,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ 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,@@ -164,13 +183,13 @@ async fn spawn_async_via_driver_tool_using_jobs(jobs: Option<tinyagents_harness_tools::subagents::SubAgentJobRegistry>,continuation: Option<(SubagentTaskKey, SubagentResume)>,completion: impl Fn(- String,- Result<SubagentRunOutcome, String>,- bool,- ) -> Pin<Box<dyn Future<Output = ()> + Send>>- + Send- + Sync- + 'static,+ String,+ Result<SubagentRunOutcome, String>,+ bool,+ ) -> Pin<Box<dyn Future<Output = ()> + Send>>+ + Send+ + Sync+ + 'static,) -> Result<String, SubagentRunError> {let task_id = continuation.as_ref()