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
fix(agent): handle missing provider in subagent host ops
Steven Enamakelb85ce07ba3a6
diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rsindex de4923d8e0..0cc943e656 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/mod.rs@@ -11,7 +11,7 @@//!//! | File | Contents |//! | ------------------- | -------------------------------------------------------------- |-//! | `provider.rs` | `resolve_subagent_source`, `user_is_signed_in_to_composio`, `LazyToolkitResolver` |+//! | `provider.rs` | `resolve_subagent_source`, `user_is_signed_in_to_composio` |//! | `prompt.rs` | Role-contract suffix, `append_subagent_role_contract`, `dedup_tool_specs_by_name` |//! | `runner.rs` | `run_subagent`, `run_typed_mode` |//! | `graph.rs` | `run_subagent_via_graph` — the sub-agent turn graph + tools |@@ -48,16 +48,12 @@ pub(crate) use provider::resolve_subagent_source;// Re-exports for test companion modules that use `use super::*`.// These provide the same flat namespace the original ops.rs had.// `append_subagent_role_contract` is already re-exported (pub(crate)) above.-// `dedup_tool_specs_by_name` and `normalize_slug` are private in their source-// modules and cannot be `pub`-re-exported; a plain `use` still makes them+// `dedup_tool_specs_by_name` is private in its source+// module and cannot be `pub`-re-exported; a plain `use` still makes them// reachable from the `#[cfg(test)]` companion modules via their `use super::*`// (descendants can name ancestor-private imports).#[cfg(test)]use prompt::dedup_tool_specs_by_name;-#[cfg(test)]-use provider::normalize_slug;-#[cfg(test)]-pub(super) use provider::LazyToolkitResolver;// filter_tool_indices lives in tool_prep (sibling of ops).#[cfg(test)]pub(super) use super::tool_prep::filter_tool_indices;diff --git a/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs b/crates/openhuman-core/src/agent/subagent_host/ops/provider.rsindex b9aa8d8117..e26a629a01 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs@@ -104,207 +104,3 @@ pub(crate) fn resolve_subagent_source(pub(crate) fn user_is_signed_in_to_composio(config: &crate::config::Config) -> bool {crate::integrations::composio::client::create_composio_client(config).is_ok()}--// ─────────────────────────────────────────────────────────────────────────────-// Lazy toolkit resolver-// ─────────────────────────────────────────────────────────────────────────────--/// Lazy resolver that lets `integrations_agent` recover when the model-/// calls a Composio action slug that exists in the bound toolkit's full-/// catalogue but was filtered out of the up-front fuzzy top-K. On a-/// match we build the [`ComposioActionTool`] on demand so the call-/// dispatches normally instead of dead-ending in-/// `Error: tool '...' is not available`.-///-/// Holds an [`Arc<Config>`] rather than a pre-baked-/// [`crate::integrations::composio::ComposioClient`] so the live-/// `composio.mode` toggle is honoured per execute — see-/// [`crate::integrations::composio::ComposioActionTool`] and issue #1710.-///-/// ## Tool caching (#5119)-///-/// `resolve()` caches the built [`ComposioActionTool`] (and therefore its-/// [`ContractGate`]) per slug so that a given action reuses the same gate-/// instance across multiple `resolve()` calls. This is forward-looking: the-/// `lazy_resolver` is not yet wired for production dispatch (#4249 1b), but-/// when it is, caching prevents the fresh-gate-per-call problem that would-/// cause every resolution to surface the contract instead of executing.-/// Additionally, the [`ContractGate`] itself has a process-wide auto-proceed-/// safety net that handles the re-delegation pattern even without caching.-pub(crate) struct LazyToolkitResolver {- pub(super) config: std::sync::Arc<crate::config::Config>,- pub(super) actions: Vec<crate::agent::prompts::ConnectedIntegrationTool>,- /// Cache of resolved tools keyed by action slug. Once a tool is built- /// for a slug, subsequent `resolve()` calls for the same slug reuse the- /// cached instance — sharing its [`ContractGate`] state (#5119).- #[allow(dead_code)] // used via pub(super) from tests- pub(super) resolved:- std::sync::Mutex<std::collections::HashMap<String, std::sync::Arc<dyn tinytools::Tool>>>,-}--/// Minimum normalized-slug length before the prefix/superstring tier in-/// [`LazyToolkitResolver::find_action`] engages (#3152). Below this, a stray-/// short slug (`notion`, `gmail`) would prefix-match too many actions; the-/// uniqueness check would reject it anyway, but the length gate makes the-/// intent explicit and skips needless scans.-const TIER4_MIN_SLUG_LEN: usize = 8;--impl LazyToolkitResolver {- /// Resolve a `ComposioActionTool` for `name`, caching the built tool per- /// slug so subsequent calls for the same slug return the same- /// [`ContractGate`] instance (#5119).- ///- /// ## Caching- ///- /// Tools are cached by slug in the `resolved` map. The first call for a- /// slug builds the tool and stores it; subsequent calls return the cached- /// `Arc<dyn Tool>`, sharing the [`ContractGate`] state across calls. This- /// prevents the fresh-gate-per-call problem: the contract is surfaced at- /// most once per resolver instance, and the retry proceeds normally.- ///- /// Additionally, the [`ContractGate`] has a process-wide auto-proceed- /// safety net that fires when too many fresh gate instances have all- /// surfaced the same contract without executing (#5119). This handles- /// the cross-spawn re-delegation pattern even when caching is bypassed.- pub(super) fn resolve(&self, name: &str) -> Option<std::sync::Arc<dyn tinytools::Tool>> {- // Check cache first — returns the same Arc (and therefore the same- // ContractGate) for repeated resolve calls on the same slug.- {- let cache = self- .resolved- .lock()- .unwrap_or_else(|poisoned| poisoned.into_inner());- if let Some(cached) = cache.get(name) {- tracing::trace!(- target: "subagent_runner",- slug = %name,- "[subagent_host] returning cached composio tool"- );- return Some(cached.clone());- }- }-- let action = self.find_action(name)?;- let tool: std::sync::Arc<dyn tinytools::Tool> =- std::sync::Arc::new(crate::integrations::composio::ComposioActionTool::new(- self.config.clone(),- action.name.clone(),- action.description.clone(),- action.parameters.clone(),- ));-- // Store in cache for future lookups.- {- let mut cache = self- .resolved- .lock()- .unwrap_or_else(|poisoned| poisoned.into_inner());- cache.insert(action.name.clone(), tool.clone());- }-- Some(tool)- }-- /// Match a model-supplied tool name to a real toolkit action, tolerant- /// of the near-miss slugs models routinely emit — case differences and- /// separator/prefix drift (bug-report-2026-05-26 A2). Tries, in order:- /// exact, case-insensitive, then a normalized alphanumeric match- /// (accepted only when **unique**, so a fabricated slug can't silently- /// resolve to the wrong action — those still fall through to the- /// "tool not available" error, which lists `known_slugs` for the model- /// to self-correct).- fn find_action(&self, name: &str) -> Option<&crate::agent::prompts::ConnectedIntegrationTool> {- if let Some(action) = self.actions.iter().find(|a| a.name == name) {- return Some(action);- }- if let Some(action) = self- .actions- .iter()- .find(|a| a.name.eq_ignore_ascii_case(name))- {- tracing::debug!(- requested = %name,- matched = %action.name,- "[subagent_host] resolved tool by case-insensitive match"- );- return Some(action);- }- let norm = normalize_slug(name);- if !norm.is_empty() {- let mut matches = self- .actions- .iter()- .filter(|a| normalize_slug(&a.name) == norm);- if let Some(action) = matches.next() {- if matches.next().is_none() {- tracing::info!(- requested = %name,- matched = %action.name,- "[subagent_host] resolved tool by normalized-slug match"- );- return Some(action);- }- // Ambiguous: 2+ actions normalize to the same slug (e.g.- // `read_file` and `ReadFile` → `readfile`). We deliberately- // refuse to guess. Warn (not debug): a slug collision is a- // toolkit configuration anomaly that should surface in normal- // operator logs, not stay hidden behind debug filtering.- tracing::warn!(- requested = %name,- norm = %norm,- "[subagent_host] ambiguous normalized-slug match — multiple actions resolve to the same slug; not resolving"- );- return None;- }-- // Tier 4: unique prefix/superstring match (#3152). Models- // routinely emit a TRUNCATED action slug — `NOTION_SEARCH_NOTION`- // for the catalogued `NOTION_SEARCH_NOTION_PAGE` — or, less often,- // a suffixed one. Accept only when exactly one action's normalized- // slug extends the request (or vice-versa). Gated on a non-trivial- // request length so a short or hallucinated slug can't fan out- // across many actions, and strictly unique so a near-miss WRITE- // can never silently dispatch to the wrong action (data-integrity:- // a mis-resolved create/update would touch the wrong resource).- if norm.len() >= TIER4_MIN_SLUG_LEN {- let mut prefix_matches = self.actions.iter().filter(|a| {- let cand = normalize_slug(&a.name);- !cand.is_empty() && (cand.starts_with(&norm) || norm.starts_with(&cand))- });- if let Some(action) = prefix_matches.next() {- if prefix_matches.next().is_none() {- tracing::info!(- requested = %name,- matched = %action.name,- "[subagent_host] resolved tool by unique prefix/superstring match"- );- return Some(action);- }- tracing::warn!(- requested = %name,- norm = %norm,- "[subagent_host] ambiguous prefix/superstring match — multiple actions share the slug prefix; not resolving"- );- }- }- }- None- }-- /// Slugs from the bound toolkit, for inclusion in unknown-tool- /// errors so the model can self-correct without burning a turn.- pub(super) fn known_slugs(&self) -> Vec<&str> {- self.actions.iter().map(|a| a.name.as_str()).collect()- }-}--/// Lowercased, non-alphanumerics stripped — collapses separator/prefix-/// drift (`GOOGLESLIDES_BATCH_UPDATE` vs `googleslides_batch_update`) so-/// near-miss tool slugs still resolve, while genuinely different slugs-/// (e.g. a hallucinated `GMAIL_GET_LAST_3_MESSAGES`) stay distinct.-pub(super) fn normalize_slug(s: &str) -> String {- s.chars()- .filter(|c| c.is_ascii_alphanumeric())- .map(|c| c.to_ascii_lowercase())- .collect()-}