Skip to content

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

refactor(orchestration): remove fleet tool availability module

Steven Enamakelac4daf42a400
diff --git a/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs b/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs
deleted file mode 100644
index 0506dea2aa..0000000000
--- a/crates/openhuman-core/src/agent/orchestration/fleet_tools.rs
+++ /dev/null
@@ -1,115 +0,0 @@
-//! 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_registry::host_definition::AgentDefinitionRegistry;
-use tinyagents_definition::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::current() 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)
- }
-
- /// Resolve the set from a turn's *effective* visible tool names — the
- /// live, already-filtered membership set (hides, named restrictions, and
- /// policy narrowing all applied), as opposed to [`Self::for_parent`]'s
- /// static read of the parent's registered definition. Prefer this
- /// whenever the caller already has that snapshot: a hide or restriction
- /// applied mid-session can narrow a turn's real tool surface below what
- /// the definition alone would suggest, and offering a control absent
- /// from this snapshot invites a denied tool call.
- pub(crate) fn from_visible_tool_names(names: &std::collections::HashSet<String>) -> Self {
- let available = FLEET_TOOLS
- .iter()
- .copied()
- .filter(|name| names.contains(*name))
- .collect();
- Self { available }
- }
-
- /// 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.rs
deleted file mode 100644
index 7073446110..0000000000
--- a/crates/openhuman-core/src/agent/orchestration/fleet_tools_tests.rs
+++ /dev/null
@@ -1,67 +0,0 @@
-use super::FleetToolSet;
-use tinyagents_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_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_registry::host_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.rs
index 4bd2d700fc..dfc004e9e6 100644
--- a/crates/openhuman-core/src/agent/orchestration/mod.rs
+++ b/crates/openhuman-core/src/agent/orchestration/mod.rs
@@ -18,7 +18,6 @@ pub(crate) mod completion_notice;
pub(crate) mod completion_owners;
pub(crate) mod completion_target;
pub(crate) mod delivery_drain;
-pub(crate) mod fleet_tools;
#[path = "parent_context/builder.rs"]
pub(crate) mod parent_context;
pub(crate) mod running_subagents;
diff --git a/crates/openhuman-core/src/tools/toolpacks/registry.rs b/crates/openhuman-core/src/tools/toolpacks/registry.rs
index fa9f3eb876..0b278123b3 100644
--- a/crates/openhuman-core/src/tools/toolpacks/registry.rs
+++ b/crates/openhuman-core/src/tools/toolpacks/registry.rs
@@ -383,28 +383,6 @@ pub const PACKS: &[ToolPack] = &[
},
];
-/// The fleet tools are deliberately NOT a pack, and this is worth stating
-/// because they look like an obvious 1.6k-token candidate.
-///
-/// `steer_subagent`, `wait_subagent`, `close_subagent`, `list_subagents`,
-/// `continue_subagent`, `wait`, and `wait_loop` are
-/// needed *reactively*, mid-turn — exactly when an async worker returns or
-/// pauses on `ask_user_clarification`. A load round-trip at that moment is the
-/// worst possible time to add one, and a `continue_subagent` the model cannot
-/// see is the known infinite-re-delegation failure mode (#4291): the only
-/// continuation left is a fresh stateless sub-agent that asks the same
-/// question again.
-#[cfg(test)]
-pub(crate) const DELIBERATELY_UNPACKED_FLEET_TOOLS: &[&str] = &[
- "steer_subagent",
- "wait_subagent",
- "close_subagent",
- "list_subagents",
- "continue_subagent",
- "wait",
- "wait_loop",
-];
-
/// The lookup surface over [`PACKS`] handed to the generic `use_skill` tool
/// (`tinyagents_harness_tools::skills`). `NOT_FOUND_MARKER` is the host's status
/// vocabulary, so a "no such skill / tool" result classifies as `NotFound`.
diff --git a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs
index 42fa9ada38..e3e35c7bb9 100644
--- a/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs
+++ b/crates/openhuman-core/src/tools/toolpacks/toolpacks_tests.rs
@@ -507,19 +507,6 @@ fn every_owner_names_a_pack_tool_it_actually_declares() {
}
}
-#[test]
-fn the_reactive_fleet_tools_are_never_packed() {
- // Packing these would put a `use_skill` round-trip between an async
- // worker returning and the parent being able to steer or collect it.
- // See `DELIBERATELY_UNPACKED_FLEET_TOOLS` for the full reasoning.
- for name in registry::DELIBERATELY_UNPACKED_FLEET_TOOLS {
- assert!(
- registry::pack_for_tool(name).is_none(),
- "`{name}` is needed reactively mid-turn and must stay advertised"
- );
- }
-}
-
#[path = "toolpacks_tests_scoping_and_visibility_tests.rs"]
mod scoping_and_visibility_tests;