Skip to content

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

refactor(agent): centralize subagent spawn tool name checks

Steven Enamakel2651c8021f8d
diff --git a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
index b5998cd11e..a293db198a 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
@@ -35,19 +35,15 @@ pub(crate) fn subagent_prompt_protocol(
/// delegates. Nested spawns would create a recursion tree the harness
/// is not designed to budget, cost, or observe.
///
-/// Matches:
-/// * the generic `spawn_subagent` meta-tool (arbitrary archetype by id);
-/// * every synthesised per-archetype `delegate_*` tool
+/// Matches TinyAgents' spawn-tool list, the host's `continue_subagent` tool,
+/// and every synthesised per-archetype `delegate_*` tool
/// ([`crate::tools::orchestrator_tools::collect_orchestrator_tools`]
/// emits `delegate_code_executor`, `delegate_planner`, …).
///
-/// Kept as a tight prefix/exact match rather than a registry lookup so
-/// the strip is cheap to run inside [`super::ops::run_typed_mode`]'s
-/// filter pass. If the delegation-tool naming scheme changes, update
-/// this function and the corresponding generator in
-/// `orchestrator_tools.rs` together.
+/// The shared static names stay aligned with TinyAgents; registry lookup is
+/// needed only for host-defined, unprefixed `delegate_name` overrides.
pub(super) fn is_subagent_spawn_tool(name: &str) -> bool {
- if name == "spawn_subagent" || name.starts_with("delegate_") {
+ if crate::agent::tinyagents::is_subagent_spawn_or_delegate_tool(name) {
return true;
}
// Synthesised delegation tools are named by the target agent's
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs
index d616966f09..5bd60dd6ff 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_policy.rs
@@ -158,18 +158,14 @@ pub(crate) fn tool_call_limit(max_iterations: usize, cap: Option<usize>) -> usiz
/// the `pub(super)` runner helper) so the invariant travels with the
/// registration site that enforces it.
///
-/// **This is a strict subset of the caller-side strip**, not a mirror of it
-/// (issue #6157). `subagent_host::tool_prep::is_subagent_spawn_tool` also
-/// resolves each archetype's `delegate_name` override through the definition
-/// registry — `manage_tasks`, `create_image`, `setup_skills`, … — none of which
-/// carry the `delegate_` prefix this match relies on. Matching them here would
-/// put a registry lookup on the per-tool registration loop, so the caller
-/// stays responsible for the override names: every path that feeds `allowed`
-/// runs `is_subagent_spawn_tool` first, including the dynamic per-spawn tools
-/// (`subagent_host::ops::runner`). Widen this predicate in lockstep if that
-/// ever stops being true.
+/// This uses TinyAgents' canonical spawn-tool names and also strips the host's
+/// continuation tool and synthesized `delegate_*` tools. The caller-side
+/// filter additionally resolves unprefixed `delegate_name` overrides through
+/// the definition registry before constructing a child's tool surface.
pub(crate) fn is_subagent_spawn_or_delegate_tool(name: &str) -> bool {
- name == "spawn_subagent" || name.starts_with("delegate_") || name == "spawn_worker_thread"
+ tinyagents_definition::SPAWN_TOOL_NAMES.contains(&name)
+ || name.starts_with("delegate_")
+ || name == "continue_subagent"
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/profiles/capabilities.rs b/crates/openhuman-core/src/profiles/capabilities.rs
index 16bff7a271..5aa6650fd9 100644
--- a/crates/openhuman-core/src/profiles/capabilities.rs
+++ b/crates/openhuman-core/src/profiles/capabilities.rs
@@ -122,10 +122,8 @@ impl ProfileCapabilities {
| crate::core::all::DomainGroup::Flows
| crate::core::all::DomainGroup::Mcp
)
- && !matches!(
- name,
- "http_request" | "spawn_agent" | "spawn_async_subagent" | "use_skill"
- )
+ && !matches!(name, "http_request" | "use_skill" | "continue_subagent")
+ && !tinyagents_definition::SPAWN_TOOL_NAMES.contains(&name)
&& !name.starts_with("delegate_")
&& !name.starts_with("mcp_")
&& crate::tools::toolpacks::pack_for_tool(name)