Skip to content

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

fix(profiles): block all spawn and delegate tools from profile capabilities

Steven Enamakel45ce94f38980
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 dceec3ff7c..5a01444e85 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep.rs
@@ -35,15 +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 TinyAgents' spawn-tool list, the host's `continue_subagent` tool,
-/// and every synthesised per-archetype `delegate_*` tool
+/// Matches TinyAgents' spawn-tool list, the host's `delegate` and
+/// `continue_subagent` tools, and every synthesised per-archetype `delegate_*` tool
/// ([`crate::tools::orchestrator_tools::collect_orchestrator_tools`]
/// emits `delegate_code_executor`, `delegate_planner`, …).
///
/// 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/subagent_host/tool_prep_tests.rs b/crates/openhuman-core/src/agent/subagent_host/tool_prep_tests.rs
index 24e61ec5f4..33cc2cf76b 100644
--- a/crates/openhuman-core/src/agent/subagent_host/tool_prep_tests.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/tool_prep_tests.rs
@@ -10,6 +10,7 @@ fn custom_delegate_is_treated_as_spawn_tool() {
#[test]
fn child_tool_surface_never_contains_any_spawn_or_continuation_tool() {
let tools: Vec<Box<dyn Tool>> = [
+ "delegate",
"spawn_subagent",
"spawn_async_subagent",
"spawn_parallel_agents",
diff --git a/crates/openhuman-core/src/profiles/capabilities.rs b/crates/openhuman-core/src/profiles/capabilities.rs
index 16bff7a271..d1b80c50c0 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")
+ && !super::provider_settings::is_profile_spawn_tool(name)
&& !name.starts_with("delegate_")
&& !name.starts_with("mcp_")
&& crate::tools::toolpacks::pack_for_tool(name)
diff --git a/crates/openhuman-core/src/profiles/capabilities_tests.rs b/crates/openhuman-core/src/profiles/capabilities_tests.rs
index e9270a9d71..9f24eeeaa0 100644
--- a/crates/openhuman-core/src/profiles/capabilities_tests.rs
+++ b/crates/openhuman-core/src/profiles/capabilities_tests.rs
@@ -11,5 +11,14 @@ fn profile_capabilities_deny_the_registered_spawn_tool() {
None,
);
- assert!(!capabilities.admits_capability("spawn_subagent"));
+ for name in tinyagents_definition::SPAWN_TOOL_NAMES
+ .iter()
+ .copied()
+ .chain(["delegate", "delegate_graph", "continue_subagent"])
+ {
+ assert!(
+ !capabilities.admits_capability(name),
+ "profiles must not admit spawn tool {name}"
+ );
+ }
}
diff --git a/crates/openhuman-core/src/profiles/provider_settings.rs b/crates/openhuman-core/src/profiles/provider_settings.rs
index c807b58e7e..efb601aba5 100644
--- a/crates/openhuman-core/src/profiles/provider_settings.rs
+++ b/crates/openhuman-core/src/profiles/provider_settings.rs
@@ -13,6 +13,19 @@ use crate::core::runtime::SaasConfig;
use std::collections::{BTreeMap, HashSet};
use std::sync::Arc;
use tinysearch_bus::Role;
+
+/// Whether a tool name belongs to a spawn/delegation surface that hosted
+/// profiles must keep outside their tool capabilities.
+pub(crate) fn is_profile_spawn_tool(name: &str) -> bool {
+ crate::agent::tinyagents::is_subagent_spawn_or_delegate_tool(name)
+ || crate::agent_registry::host_definition::AgentDefinitionRegistry::current()
+ .is_some_and(|registry| {
+ registry
+ .list()
+ .iter()
+ .any(|definition| definition.delegate_name.as_deref() == Some(name))
+ })
+}
/// Search capability vocabulary for operator presentation settings.
pub use tinysearch_bus::Role as SearchRole;
@@ -249,16 +262,8 @@ fn collides(name: &str) -> bool {
|| super::tools::HARD_DENIED_PREFIXES
.iter()
.any(|prefix| name.starts_with(prefix))
- || matches!(
- name,
- "shell"
- | "memory"
- | "show_page"
- | "search"
- | "http_request"
- | "spawn_agent"
- | "spawn_async_subagent"
- )
+ || matches!(name, "shell" | "memory" | "show_page" | "search" | "http_request")
+ || is_profile_spawn_tool(name)
}
#[cfg(test)]
diff --git a/crates/openhuman-core/src/profiles/provider_settings_tests.rs b/crates/openhuman-core/src/profiles/provider_settings_tests.rs
index 05df8359b1..19a9ac0ecd 100644
--- a/crates/openhuman-core/src/profiles/provider_settings_tests.rs
+++ b/crates/openhuman-core/src/profiles/provider_settings_tests.rs
@@ -81,6 +81,12 @@ fn rejects_collisions_duplicates_unsafe_identifiers_and_alias_chains() {
" ",
"shell",
"spawn_subagent",
+ "spawn_async_subagent",
+ "spawn_parallel_agents",
+ "spawn_worker_thread",
+ "delegate",
+ "delegate_graph",
+ "continue_subagent",
"memory",
"show_page",
"web_answer_tool",