Skip to content

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

feat(subagent): frame subagents with orchestrator role when they can spawn

Steven Enamakel3178855526e2
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
index 1de1dea4d0..53377218f6 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/prompt.rs
@@ -9,7 +9,7 @@ use tinyagents_harness::artifacts::{
render_artifact_offload_contract, should_render_offload_contract, ARTIFACT_OFFLOAD_HEADING,
};
-/// Compose the leaf role framing with the host's artifact-tool prompt policy.
+/// Compose child role framing with the host's artifact-tool prompt policy.
pub(crate) fn compose_subagent_system_prompt(
base_prompt: String,
agent_id: &str,
@@ -17,11 +17,19 @@ pub(crate) fn compose_subagent_system_prompt(
task_prompt: &str,
spawn_depth: usize,
) -> String {
+ let role = if visible_tool_names
+ .iter()
+ .any(|name| crate::agent::subagent_host::tool_prep::is_subagent_spawn_tool(name))
+ {
+ tinyagents_orchestration::subagent::SubagentRole::Orchestrator
+ } else {
+ tinyagents_orchestration::subagent::SubagentRole::Leaf
+ };
let framed = format!(
"{}\n\n{}",
base_prompt.trim_end(),
tinyagents_orchestration::subagent::subagent_framing(
- tinyagents_orchestration::subagent::SubagentRole::Leaf,
+ role,
spawn_depth,
task_prompt,
)
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
index 22411a5389..383ea4c881 100644
--- a/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/ops/runner.rs
@@ -15,7 +15,7 @@ use crate::agent::prompts::{PromptContext, SubagentRenderOptions};
use crate::agent::session_host::dedup_visible_tool_specs;
use crate::agent::subagent_host::definition_iter_cap;
use crate::agent::subagent_host::tool_prep::{
- filter_tool_indices, is_subagent_spawn_tool, subagent_prompt_protocol,
+ filter_tool_indices_with_nested_spawn, is_subagent_spawn_tool, subagent_prompt_protocol,
};
use crate::agent::subagent_host::types::{
SubagentMode, SubagentRunError, SubagentRunOptions, SubagentRunOutcome,