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(spawn_subagent): extract definition lookup into macro
Steven Enamakel32eeea7ecc15
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rsindex 006e1072ec..1bd1f35969 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_host_impl.rs@@ -42,39 +42,7 @@ impl SpawnSubagentTool {)));}- let registry =- match AgentDefinitionRegistry::for_core_context(run_context.dispatch_ctx().into_core())- {- Some(registry) => registry,- None => {- return Ok(ToolResult::error(- "spawn_subagent: AgentDefinitionRegistry has not been initialised",- ));- }- };- let definition = match registry.get(&agent_id).cloned() {- Some(definition) => definition,- None => {- let available: Vec<&str> = registry.list().iter().map(|d| d.id.as_str()).collect();- return Ok(ToolResult::error(format!(- "spawn_subagent: unknown agent_id '{agent_id}'. Available: {}",- available.join(", ")- )));- }- };-- if !parent.allowed_subagent_ids.contains(&definition.id) {- log::warn!(- "[spawn_subagent] blocked subagent outside allowlist parent={} requested={} allowed={:?}",- parent.agent_definition_id,- definition.id,- parent.allowed_subagent_ids- );- return Ok(ToolResult::error(format!(- "spawn_subagent: agent '{}' is not in parent agent '{}' subagents.allowlist",- definition.id, parent.agent_definition_id- )));- }+ spawn_subagent_definition!(definition, run_context, agent_id, parent);let parent_session = parent.session_id.clone();let progress_sink = parent.on_progress.clone();diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_preflight.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_preflight.rsindex e4145c98b1..7c9701fe55 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_preflight.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_preflight.rs@@ -21,3 +21,42 @@ macro_rules! spawn_subagent_preflight {};};}++macro_rules! spawn_subagent_definition {+ ($definition:ident, $run_context:ident, $agent_id:ident, $parent:ident) => {+ let registry = match AgentDefinitionRegistry::for_core_context(+ $run_context.dispatch_ctx().into_core(),+ ) {+ Some(registry) => registry,+ None => {+ return Ok(ToolResult::error(+ "spawn_subagent: AgentDefinitionRegistry has not been initialised",+ ));+ }+ };+ let $definition = match registry.get(&$agent_id).cloned() {+ Some(definition) => definition,+ None => {+ let available: Vec<&str> = registry.list().iter().map(|d| d.id.as_str()).collect();+ return Ok(ToolResult::error(format!(+ "spawn_subagent: unknown agent_id '{}'. Available: {}",+ $agent_id,+ available.join(", ")+ )));+ }+ };++ if !$parent.allowed_subagent_ids.contains(&$definition.id) {+ log::warn!(+ "[spawn_subagent] blocked subagent outside allowlist parent={} requested={} allowed={:?}",+ $parent.agent_definition_id,+ $definition.id,+ $parent.allowed_subagent_ids+ );+ return Ok(ToolResult::error(format!(+ "spawn_subagent: agent '{}' is not in parent agent '{}' subagents.allowlist",+ $definition.id, $parent.agent_definition_id+ )));+ }+ };+}