Skip to content

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

fix(agent): require live parents for orchestration tools

Steven Enamakel170a084248d0
diff --git a/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs b/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs
index 4b72681123..5a161b2178 100644
--- a/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs
+++ b/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/run.rs
@@ -26,10 +26,8 @@ pub(crate) async fn run_spawn_parallel_tasks_with_cancellation_and_workspace(
cancel: CancellationToken,
parent_workspace_descriptor: Option<WorkspaceDescriptor>,
run_context: crate::agent::tinyagents::host::OpenHumanRunContext,
- live_parent: Option<
- &tinyagents_harness::context::RunContext<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ live_parent: &tinyagents_harness::context::RunContext<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
>,
) -> Result<SpawnParallelGraphOutcome, String> {
let parent = match run_context.parent.clone() {
diff --git a/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/workers.rs b/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/workers.rs
index b9759fa3ac..f38d6e92ff 100644
--- a/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/workers.rs
+++ b/crates/openhuman-core/src/agent/orchestration/spawn_parallel_graph/workers.rs
@@ -8,7 +8,7 @@ use tinyagents_graph::parallel::{map_reduce, FailurePolicy, ParallelOptions};
use tinyagents_harness::{CancellationToken, TinyAgentsError};
use crate::agent::subagent_host::{
- run_subagent, run_subagent_with_parent, SubagentRunOptions, SubagentRunStatus,
+ run_subagent_with_parent, SubagentRunOptions, SubagentRunStatus,
};
use super::staging::WorkerDispatchMode;
@@ -19,10 +19,8 @@ pub(crate) async fn run_spawn_parallel_workers(
action_root: Option<PathBuf>,
cancel: CancellationToken,
run_context: crate::agent::tinyagents::host::OpenHumanRunContext,
- live_parent: Option<
- &tinyagents_harness::context::RunContext<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ live_parent: &tinyagents_harness::context::RunContext<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
>,
) -> tinyagents_harness::Result<Vec<ParallelAgentResult>> {
let n = prepared.len();
@@ -109,10 +107,8 @@ async fn run_one_parallel_task(
worker: SpawnParallelWorker,
repo_root: Option<PathBuf>,
run_context: crate::agent::tinyagents::host::OpenHumanRunContext,
- live_parent: Option<
- &tinyagents_harness::context::RunContext<
- crate::agent::tinyagents::host::OpenHumanRunContext,
- >,
+ live_parent: &tinyagents_harness::context::RunContext<
+ crate::agent::tinyagents::host::OpenHumanRunContext,
>,
) -> ParallelAgentResult {
let SpawnParallelWorker {
@@ -155,11 +151,8 @@ async fn run_one_parallel_task(
workspace_descriptor,
run_queue: None,
};
- let run_result = if let Some(parent) = live_parent {
- run_subagent_with_parent(parent, definition.clone(), prompt.clone(), options).await
- } else {
- run_subagent(&definition, &prompt, options).await
- };
+ let run_result =
+ run_subagent_with_parent(live_parent, definition.clone(), prompt.clone(), options).await;
// After the worker finishes, snapshot the worktree's changed files +
// dirty status so the parent can detect cross-worker overlaps and the UI
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rs
index c130c504d9..84dddc6e84 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_parallel_agents.rs
@@ -79,8 +79,8 @@ impl ToolDispatch<(), crate::agent::tinyagents::host::OpenHumanRunContext>
/// Executes the graph from explicitly supplied parent-run values.
///
-/// This is shared by the typed harness dispatch and standalone tool execution;
-/// neither path consults ambient run state.
+/// This is shared by typed harness callers and requires their live parent;
+/// standalone raw-tool execution fails closed.
pub(crate) async fn execute_spawn_parallel_agents(
args: serde_json::Value,
cancellation: tinyagents_harness::CancellationToken,
@@ -88,6 +88,11 @@ pub(crate) async fn execute_spawn_parallel_agents(
run_context: crate::agent::tinyagents::host::OpenHumanRunContext,
live_parent: Option<&RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>>,
) -> anyhow::Result<ToolResult> {
+ let Some(live_parent) = live_parent else {
+ return Ok(ToolResult::error(
+ "spawn_parallel_agents requires a live harness run context.",
+ ));
+ };
tracing::debug!("[spawn_parallel_agents] execute entry");
let tasks = match parse_parallel_agent_tasks(&args) {
Ok(tasks) => tasks,
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs
index baea092d32..a8e1685562 100644
--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs
+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_worker_thread.rs
@@ -10,7 +10,7 @@
//! another worker thread.
use crate::agent::harness::definition::AgentDefinitionRegistry;
-use crate::agent::subagent_host::{run_subagent, run_subagent_with_parent, SubagentRunOptions};
+use crate::agent::subagent_host::{run_subagent_with_parent, SubagentRunOptions};
use crate::memory::conversations;
use async_trait::async_trait;
use serde_json::json;
@@ -177,6 +177,11 @@ impl SpawnWorkerThreadTool {
run_context: crate::agent::tinyagents::host::OpenHumanRunContext,
live_parent: Option<&RunContext<crate::agent::tinyagents::host::OpenHumanRunContext>>,
) -> anyhow::Result<ToolResult> {
+ let Some(live_parent) = live_parent else {
+ return Ok(ToolResult::error(
+ "spawn_worker_thread requires a live harness run context.",
+ ));
+ };
let started = std::time::Instant::now();
let agent_id = args
@@ -342,11 +347,9 @@ impl SpawnWorkerThreadTool {
"[spawn_worker_thread] dispatching run_subagent"
);
- let run = if let Some(parent) = live_parent {
- run_subagent_with_parent(parent, definition.clone(), prompt.clone(), options).await
- } else {
- run_subagent(definition, &prompt, options).await
- };
+ let run =
+ run_subagent_with_parent(live_parent, definition.clone(), prompt.clone(), options)
+ .await;
match run {
Ok(outcome) => {
let owns_effects = outcome.should_emit_lifecycle_effects();
diff --git a/crates/openhuman-core/src/agent/tinyagents/model.rs b/crates/openhuman-core/src/agent/tinyagents/model.rs
index 5e54861f19..e5fe8c4fc3 100644
--- a/crates/openhuman-core/src/agent/tinyagents/model.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/model.rs
@@ -199,8 +199,10 @@ pub(crate) fn prompt_guided_text_response(text: String, request: &ModelRequest)
return ModelResponse::assistant(text);
}
- let response =
- tinyagents_harness::tool::apply_prompt_tool_calls(ModelResponse::assistant(text.clone()));
+ let response = tinyinference_llm::prompt_tools::recover_tool_calls(
+ ModelResponse::assistant(text.clone()),
+ &request.tools,
+ );
if !response.message.tool_calls.is_empty() {
return response;
}
diff --git a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
index 541b012e27..3900f8e5bf 100644
--- a/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
+++ b/crates/openhuman-core/src/mcp/server/tools/dispatch.rs
@@ -249,7 +249,10 @@ async fn core_tool_instructions() -> Result<Value, ToolCallError> {
})
.collect();
Ok(tool_text_success(
- tinyagents_harness::tool::prompt_tool_instructions(&schemas),
+ tinyinference_llm::prompt_tools::tool_instructions(
+ &schemas,
+ &tinyinference_llm::model::ToolChoice::Auto,
+ ),
))
}