Skip to content

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

refactor(orchestrator): route specialists through spawn_subagent

Steven Enamakel980ea6caaa69
diff --git a/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.md b/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.md
index 2562598696..4ce9983e80 100644
--- a/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.md
+++ b/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.md
@@ -9,15 +9,15 @@ First match wins:
- Web: `web_answer_tool` (`depth: "deep"` for research), `web_search_tool`, `web_fetch`; `provider` unset unless named. Live asks get a tool call now.
- Code, settings, crypto, OpenHuman help: `use_skill` `coding`/`system`/`web3`/`docs` first; edit and verify in the same turn.
- MCP: server tools come from `tool_search`; never guess their arguments.<!--route:mcp-->
-- Specialists: delegate tools or `use_skill`. Act on a returned `## Handoff Plan` yourself; distill replies, never paste them.
-- Reminders: skill `scheduling`, with a yes on exact timing first. Build or edit a workflow: spawn `workflow_builder` with `spawn_subagent`; find one: `flow_discovery`.
+- Specialists: use `spawn_subagent` with the specialist's `agent_id` and a self-contained prompt. Act on a returned `## Handoff Plan` yourself; distill replies, never paste them.
+- Reminders: skill `scheduling`, with a yes on exact timing first. Build or edit a workflow with `agent_id: "workflow_builder"`; find one with `agent_id: "flow_discovery"`.
## Sub-agents
- `[active_subagents]` is the truth about workers; never spawn a duplicate.
-- `spawn_subagent` only for work this reply doesn't need. Fan-out is just several spawns in one message; they run concurrently.
-- A result that gates this reply needs a delegate with `blocking: true`.
-- `awaiting_user` workers resume with `continue_subagent`; a `failed` one produced nothing: say so.
+- Spawn specialist work with `spawn_subagent{agent_id, prompt, task_key}`. Calls are asynchronous; completed results arrive automatically.
+- Reuse the same `task_key` to continue a worker, including one paused on `ask_user_clarification`. Include the user's answer in the new prompt.
+- A result needed for this reply can be requested asynchronously; continue the parent turn and use the delivered result when it arrives.
## Grounding and tool use
diff --git a/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.rs b/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.rs
index 7145a92dd2..1f7f7ed4f9 100644
--- a/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.rs
+++ b/crates/openhuman-core/src/agent_registry/agents/orchestrator/prompt.rs
@@ -142,68 +142,9 @@ pub fn build(ctx: &PromptContext<'_>) -> Result<String> {
/// turn. Only a withheld specialist needs prose, because its description is
/// the thing the model cannot see.
fn render_withheld_specialists(ctx: &PromptContext<'_>) -> String {
- // Empty is the harness's "everything is visible" sentinel, not "nothing
- // visible" — with no filter, nothing is withheld and the section is void.
- if ctx.visible_tool_names.is_empty() {
- tracing::debug!(
- agent = ctx.agent_id,
- "[orchestrator-prompt] no visible-tool filter; nothing can be withheld"
- );
- return String::new();
- }
- let Some(registry) = AgentDefinitionRegistry::current() else {
- tracing::debug!(
- "[orchestrator-prompt] no agent registry; withheld-specialist section omitted"
- );
- return String::new();
- };
- let Some(definition) = resolve_definition(&registry, ctx.agent_id) else {
- tracing::debug!(
- agent = ctx.agent_id,
- "[orchestrator-prompt] agent id does not resolve to a registry entry"
- );
- return String::new();
- };
-
- let mut rows: Vec<(String, &'static str, String)> = Vec::new();
- for entry in &definition.subagents {
- // `Skills(_)` expands to searchable integration actions, not a
- // delegate tool; the `## Connected Integrations` block covers them.
- let SubagentEntry::AgentId(agent_id) = entry else {
- continue;
- };
- // Runtime-only, never given a delegate tool — see the same skip in
- // `collect_orchestrator_tools`.
- if agent_id == "summarizer" {
- continue;
- }
- let Some(target) = registry.get(agent_id) else {
- continue;
- };
- let tool_name = target
- .delegate_name
- .clone()
- .unwrap_or_else(|| format!("delegate_{}", target.id));
- if ctx.visible_tool_names.contains(&tool_name) {
- continue;
- }
- let Some(pack) = toolpacks::pack_for_tool(&tool_name) else {
- // Not advertised and not packed: the agent is compiled out or the
- // belt never listed it, so there is no route to describe.
- continue;
- };
- rows.push((tool_name, pack.id, target.when_to_use.clone()));
- }
-
- if rows.is_empty() {
- tracing::debug!(
- agent = ctx.agent_id,
- subagents = definition.subagents.len(),
- visible = ctx.visible_tool_names.len(),
- "[orchestrator-prompt] no withheld specialists to render"
- );
- return String::new();
- }
+ let _ = ctx;
+ String::new()
+}
tracing::debug!(
count = rows.len(),
"[orchestrator-prompt] rendering withheld-specialist routing"
@@ -264,26 +205,12 @@ fn hand_off_route(ctx: &PromptContext<'_>, specialist: &str) -> Option<String> {
if !listed {
return None;
}
- let target = registry.get(specialist)?;
- let tool = target
- .delegate_name
- .clone()
- .unwrap_or_else(|| format!("delegate_{}", target.id));
- if ctx.visible_tool_names.is_empty() || ctx.visible_tool_names.contains(&tool) {
- return Some(format!("`{tool}`"));
- }
- // A packed route is only a route if this session can call `use_skill`
- // itself. A filtered belt holding neither the delegate nor `use_skill` has
- // no way to reach the specialist, and naming one anyway is the same "call a
- // tool you do not have" failure this whole block exists to end (#6302).
- if !ctx
- .visible_tool_names
- .contains(tinyagents_harness_tools::skills::USE_SKILL)
- {
- return None;
+ registry.get(specialist)?;
+ if ctx.visible_tool_names.is_empty() || ctx.visible_tool_names.contains("spawn_subagent") {
+ Some(format!("`spawn_subagent` with agent_id `{specialist}`"))
+ } else {
+ None
}
- toolpacks::pack_for_tool(&tool)
- .map(|pack| format!("`{tool}` (`use_skill` skill `{}`)", pack.id))
}
/// How this session runs an installed skill: its own `run_workflow`, on the