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
feat(orchestration): expose fleet_tools module
Steven Enamakel8c1cf9aeb7ee
diff --git a/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs b/crates/openhuman-core/src/agent/orchestration/fleet_tools.rsnew file mode 100644index 0000000000..604566c2b2--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs@@ -0,0 +1,95 @@+//! Which fleet-control tools a parent agent can actually call.+//!+//! The `[async_subagent_ref]` envelope and the ambient `[active_subagents]`+//! roster used to hard-code a full fleet vocabulary — `wait_subagent`,+//! `steer_subagent`, `wait_loop`, `close_subagent` — while the orchestrator's+//! definition deliberately dropped most of it (#5701: a sub-agent result is+//! delivered back automatically on a later turn, so nothing needs to block).+//! The model was told to call tools it did not have, spent an iteration+//! reasoning about the mismatch, and improvised (`shell echo "waiting for+//! subagent"`). Every delegation paid a full extra model call for nothing.+//!+//! This module reads the parent's definition once per render and answers+//! "does this parent see tool X?", so both texts only ever name tools that+//! are in the caller's belt.++use crate::agent::harness::definition::{AgentDefinitionRegistry, ToolScope};++/// The fleet-control tools whose availability shapes the delegation texts.+const FLEET_TOOLS: &[&str] = &[+ "steer_subagent",+ "wait_subagent",+ "wait",+ "wait_loop",+ "close_subagent",+ "continue_subagent",+ "list_subagents",+];++/// The subset of [`FLEET_TOOLS`] a given parent definition exposes.+#[derive(Debug, Clone, PartialEq, Eq)]+pub(crate) struct FleetToolSet {+ available: Vec<&'static str>,+}++impl FleetToolSet {+ /// Every fleet tool — the pre-#5701 assumption, used when the parent's+ /// definition cannot be resolved so the texts degrade to their old shape+ /// rather than to silence.+ pub(crate) fn all() -> Self {+ Self {+ available: FLEET_TOOLS.to_vec(),+ }+ }++ /// Resolve the set for `agent_definition_id` from the global registry.+ pub(crate) fn for_parent(agent_definition_id: &str) -> Self {+ let Some(registry) = AgentDefinitionRegistry::global() else {+ return Self::all();+ };+ let Some(definition) = registry.get(agent_definition_id) else {+ log::debug!(+ "[fleet_tools] parent definition '{}' not in registry; assuming full fleet vocabulary",+ agent_definition_id+ );+ return Self::all();+ };+ Self::from_scope(&definition.tools, &definition.disallowed_tools)+ }++ /// Derive the set from a definition's tool scope and denylist. A+ /// `Named` scope exposes exactly the fleet tools it lists; `Wildcard`+ /// exposes all of them. `disallowed_tools` (exact or trailing-`*`+ /// prefix) removes entries from either.+ pub(crate) fn from_scope(scope: &ToolScope, disallowed: &[String]) -> Self {+ let denied = |name: &str| {+ disallowed.iter().any(|entry| match entry.strip_suffix('*') {+ Some(prefix) => name.starts_with(prefix),+ None => entry == name,+ })+ };+ let available = FLEET_TOOLS+ .iter()+ .copied()+ .filter(|name| match scope {+ ToolScope::Wildcard => true,+ ToolScope::Named(named) => named.iter().any(|n| n == name),+ })+ .filter(|name| !denied(name))+ .collect();+ Self { available }+ }++ pub(crate) fn has(&self, tool: &str) -> bool {+ self.available.contains(&tool)+ }++ /// Whether the parent can block on or poll a worker at all.+ pub(crate) fn can_wait(&self) -> bool {+ self.has("wait_subagent")+ }+}++#[cfg(test)]+#[path = "fleet_tools_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent/orchestration/fleet_tools_tests.rs b/crates/openhuman-core/src/agent/orchestration/fleet_tools_tests.rsnew file mode 100644index 0000000000..2f0e18b18f--- /dev/null+++ b/crates/openhuman-core/src/agent/orchestration/fleet_tools_tests.rs@@ -0,0 +1,62 @@+use super::FleetToolSet;+use crate::agent::harness::definition::ToolScope;++fn named(tools: &[&str]) -> ToolScope {+ ToolScope::Named(tools.iter().map(|t| t.to_string()).collect())+}++#[test]+fn named_scope_exposes_only_listed_fleet_tools() {+ let set = FleetToolSet::from_scope(+ &named(&["spawn_async_subagent", "list_subagents", "continue_subagent", "shell"]),+ &[],+ );+ assert!(set.has("list_subagents"));+ assert!(set.has("continue_subagent"));+ assert!(!set.has("wait_subagent"));+ assert!(!set.has("steer_subagent"));+ assert!(!set.has("wait_loop"));+ assert!(!set.can_wait());+}++#[test]+fn wildcard_scope_exposes_every_fleet_tool_minus_denylist() {+ let set = FleetToolSet::from_scope(&ToolScope::Wildcard, &["wait*".to_string()]);+ assert!(set.has("steer_subagent"));+ assert!(set.has("close_subagent"));+ assert!(!set.has("wait"));+ assert!(!set.has("wait_loop"));+ assert!(!set.has("wait_subagent"));+ assert!(!set.can_wait());+}++#[test]+fn all_is_the_full_vocabulary() {+ let set = FleetToolSet::all();+ for tool in [+ "steer_subagent",+ "wait_subagent",+ "wait",+ "wait_loop",+ "close_subagent",+ "continue_subagent",+ "list_subagents",+ ] {+ assert!(set.has(tool), "{tool}");+ }+ assert!(set.can_wait());+}++/// The shipped orchestrator definition is the case that motivated this+/// module: it must not be told about wait/steer/close tools.+#[test]+fn builtin_orchestrator_has_no_wait_or_steer() {+ let registry = crate::agent::harness::definition::AgentDefinitionRegistry::builtins_only();+ let def = registry.get("orchestrator").expect("built-in orchestrator");+ let set = FleetToolSet::from_scope(&def.tools, &def.disallowed_tools);+ assert!(set.has("list_subagents"));+ assert!(set.has("continue_subagent"));+ assert!(!set.can_wait());+ assert!(!set.has("steer_subagent"));+ assert!(!set.has("close_subagent"));+}diff --git a/crates/openhuman-core/src/agent/orchestration/mod.rs b/crates/openhuman-core/src/agent/orchestration/mod.rsindex dc24338e6d..3175efefaf 100644--- a/crates/openhuman-core/src/agent/orchestration/mod.rs+++ b/crates/openhuman-core/src/agent/orchestration/mod.rs@@ -20,6 +20,7 @@ pub(crate) mod background_completions;pub(crate) mod background_delivery;pub mod command_center;pub(crate) mod delegation;+pub(crate) mod fleet_tools;mod ops;pub(crate) mod parent_context;pub(crate) mod run_ledger_finalize;