Skip to content

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

fix(agent): propagate resolved workspace to detached subagent parent

Steven Enamakel6a31feb15d0a
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 9472c3c1dc..a5b69267cd 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
@@ -80,6 +80,11 @@ impl SpawnSubagentTool {
let workspace_descriptor = tool_context
.and_then(|ctx| ctx.workspace().cloned())
.or_else(|| run_context.workspace.clone());
+ 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)
@@ -336,7 +341,7 @@ impl SpawnSubagentTool {
let completion = completion::make_completion(
dispatch.clone().into_core(),
- detached_parent.data.origin.clone(),
+ detached_parent_with_workspace.data.origin.clone(),
progress_sink.clone(),
parent.workspace_dir.clone(),
dispatch.clone(),
@@ -361,7 +366,7 @@ impl SpawnSubagentTool {
.clone()
.unwrap_or_else(|| resumed_session.subagent_session_id.clone()),
),
- run_context: detached_parent.data.child(),
+ run_context: detached_parent_with_workspace.data.child(),
worker_thread_id: session.worker_thread_id.clone(),
initial_history: None,
checkpoint_dir: Some(checkpoint_dir),
@@ -370,7 +375,7 @@ impl SpawnSubagentTool {
message_run_queue: None,
};
if let Err(error) = crate::agent::subagent_host::resume_async_via_driver_tool(
- detached_parent,
+ &detached_parent_with_workspace,
original_key,
checkpoint_resume,
definition.clone(),
@@ -425,7 +430,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,
+ &detached_parent_with_workspace,
&session.subagent_session_id,
follow_up_prompt.clone(),
)
@@ -549,7 +554,7 @@ impl SpawnSubagentTool {
task_id: task_id.clone(),
lifecycle_key: Some(
tinyagents_orchestration::subagent::SubagentTaskKey::from_context(
- detached_parent,
+ &detached_parent_with_workspace,
task_id.clone(),
parent_thread_id.clone(),
),
@@ -606,9 +611,6 @@ impl SpawnSubagentTool {
thread_id,
);
}
- let task_workspace = workspace_descriptor
- .clone()
- .unwrap_or_else(|| tinytools::WorkspaceDescriptor::new(parent.workspace_dir.clone()));
crate::agent::orchestration::completion_owners::note_driver_task(
&dispatch,
&task_id,
@@ -661,7 +663,7 @@ impl SpawnSubagentTool {
background_parent_thread_id.as_deref().unwrap_or("none")
);
let completion_core = dispatch.clone().into_core();
- let completion_origin = detached_parent.data.origin.clone();
+ let completion_origin = detached_parent_with_workspace.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();
@@ -691,7 +693,7 @@ impl SpawnSubagentTool {
model_override,
task_id: Some(task_id.clone()),
thread_id: Some(background_thread_id),
- run_context: detached_parent.data.child(),
+ run_context: detached_parent_with_workspace.data.child(),
worker_thread_id: background_worker_thread_id,
initial_history,
checkpoint_dir: None,
@@ -700,7 +702,7 @@ impl SpawnSubagentTool {
message_run_queue: None,
};
if let Err(error) = crate::agent::subagent_host::spawn_async_via_driver_tool(
- detached_parent,
+ &detached_parent_with_workspace,
definition.clone(),
background_prompt,
options,