The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(agent): allow named agents to use spawn_subagent tool
Steven Enamakel7cd9f72e3251
diff --git a/crates/openhuman-embed/src/agent/build.rs b/crates/openhuman-embed/src/agent/build.rsindex 8313bab1d9..8ae0412375 100644--- a/crates/openhuman-embed/src/agent/build.rs+++ b/crates/openhuman-embed/src/agent/build.rs@@ -246,6 +246,7 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInn// delegates only to the sub-agents its host declares, never to the// inherited built-in roster (which would otherwise come back as// `delegate_*` tools the scope never listed).+ let declares_subagents = !parts.subagents.is_empty();if matches!(definition.tools, tinyagents_definition::ToolScope::Named(_))&& !definition.tools.names_a_spawn_tool()&& !definition.subagents.is_empty()@@ -256,6 +257,9 @@ pub(crate) fn instantiate(runtime: &Runtime, spec: AgentSpec) -> Result<AgentInn);definition.subagents.clear();}+ if !host_only && declares_subagents {+ opt_named_belt_into_spawn(&mut definition.tools);+ }let definitions = own_catalogue(&catalogue, &id, &mut definition, parts.subagents)?;// ── narrowing ────────────────────────────────────────────────────────@@ -429,6 +433,22 @@ fn opt_named_belt_into_discovery(scope: &mut tinyagents_definition::ToolScope) {}}+/// Lets a named-scope agent reach only the child agents it explicitly owns.+/// The caller must clear inherited roster entries first and exclude HostOnly+/// agents, whose named empty belt is a hard prohibition on acting tools.+fn opt_named_belt_into_spawn(scope: &mut tinyagents_definition::ToolScope) {+ use tinyagents_definition::ToolScope;+ const SPAWN_SUBAGENT: &str = "spawn_subagent";+ if let ToolScope::Named(names) = scope {+ if !names.iter().any(|name| name == SPAWN_SUBAGENT) {+ names.push(SPAWN_SUBAGENT.to_string());+ log::debug!(+ "[embed][agent] declared sub-agents opt the named belt into spawn_subagent"+ );+ }+ }+}+fn validate_agent_id(id: &str) -> Result<(), String> {let bytes = id.as_bytes();if bytes.is_empty() || bytes.len() > 64 {diff --git a/crates/openhuman-embed/tests/isolation_subagents.rs b/crates/openhuman-embed/tests/isolation_subagents.rsindex 6e5829f730..0ea8978f4c 100644--- a/crates/openhuman-embed/tests/isolation_subagents.rs+++ b/crates/openhuman-embed/tests/isolation_subagents.rs@@ -105,7 +105,10 @@ fn sub_agents_stay_with_the_agent_that_declared_them() {.as_array().expect("provider request tools").iter()- .find(|tool| tool.pointer("/function/name").and_then(|v| v.as_str()) == Some("spawn_subagent"))+ .find(|tool| {+ tool.pointer("/function/name").and_then(|v| v.as_str())+ == Some("spawn_subagent")+ }).expect("canonical spawn tool schema");assert_eq!(spawn_spec.pointer("/function/parameters/properties/agent_id/enum"),@@ -203,9 +206,7 @@ fn host_only_and_disallowed_scopes_do_not_opt_into_declared_helpers() {.agent(AgentSpec::new("host-only-lead").provider(route(&host_only_provider, "host-only-model"))- .definition(- AgentDefinitionSpec::new().tools(ToolScopeSpec::HostOnly),- )+ .definition(AgentDefinitionSpec::new().tools(ToolScopeSpec::HostOnly)).subagents([("host_helper",AgentDefinitionSpec::new()@@ -220,7 +221,9 @@ fn host_only_and_disallowed_scopes_do_not_opt_into_declared_helpers() {.expect("host-only turn returns");let host_requests = chat_requests(&host_only_provider).await;assert!(!host_requests.is_empty());- assert!(!tool_names(&host_requests[0]).iter().any(|name| name == "spawn_subagent"));+ assert!(!tool_names(&host_requests[0])+ .iter()+ .any(|name| name == "spawn_subagent"));assert!(host_requests.iter().all(|request| !String::from_utf8_lossy(&request.body)