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(orchestration): handle missing subagent tool in spawn implementation
Steven Enamakel4fb51be8686c
diff --git a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rsindex 82700ee189..1042314066 100644--- a/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs+++ b/crates/openhuman-core/src/agent/orchestration/tools/spawn_subagent_tool_impl.rs@@ -17,10 +17,7 @@ impl Tool for SpawnSubagentTool {`spawn_subagent` calls each delegate a single task and never launch \workers concurrently, which serializes the whole request. See the Delegation \Guide in the system prompt for available agent_ids and when to \- use each. When delegating to `integrations_agent`, you MUST also pass \- `toolkit=\"<name>\"` naming the Composio integration the \- sub-task targets (e.g. `gmail`, `notion`); the sub-agent will \- only see that toolkit's actions."+ use each."}fn parameters_schema(&self) -> serde_json::Value {@@ -182,164 +179,6 @@ impl SpawnSubagentTool {);}- // ── integrations_agent toolkit gate ──────────────────────────────────- // integrations_agent is a platform-parameterised specialist. Every- // spawn MUST name a CONNECTED toolkit so the sub-agent only- // sees one integration's tool catalogue instead of all of- // them. We split validation into three cases so the model- // gets a precise, actionable error on every failure mode —- // nothing reaches the LLM loop unless the spawn is valid.- if definition.id == "integrations_agent" {- // The parent's `connected_integrations` Vec is frozen at- // session-start (see `session/turn.rs::fetch_connected_integrations`),- // so a toolkit the user authorised mid-thread isn't visible- // here. Refresh from the global integrations cache —- // invalidated by `ComposioConnectionCreatedSubscriber` once- // OAuth reaches ACTIVE — so the pre-flight sees the latest- // truth. Falls back to the parent's frozen list when the- // live fetch returns empty (no signed-in user, backend- // unreachable, …) so offline behaviour is unchanged.- let parent_ctx = run_context.parent.clone();- let live_integrations: Vec<crate::agent::prompts::ConnectedIntegration> = {- match crate::config::Config::load_or_init().await {- Ok(config) => {- use crate::integrations::composio::FetchConnectedIntegrationsStatus;- // Use the status-discriminating fetch so we can- // tell "user has zero active integrations" (truth- // — adopt it) apart from "backend unavailable"- // (preserve the parent's frozen snapshot so the- // pre-flight doesn't reject every toolkit during- // a transient 5xx).- match crate::integrations::composio::fetch_connected_integrations_status(- &config,- )- .await- {- FetchConnectedIntegrationsStatus::Authoritative(fresh) => {- tracing::debug!(- target: "spawn_subagent",- count = fresh.len(),- "[spawn_subagent] refreshed connected_integrations for pre-flight"- );- fresh- }- FetchConnectedIntegrationsStatus::Unavailable => {- tracing::debug!(- target: "spawn_subagent",- "[spawn_subagent] integrations backend unavailable; falling back to parent's frozen list"- );- parent_ctx- .as_ref()- .map(|p| p.connected_integrations.clone())- .unwrap_or_default()- }- }- }- Err(e) => {- tracing::debug!(- target: "spawn_subagent",- error = %e,- "[spawn_subagent] config load failed; falling back to parent's frozen list"- );- parent_ctx- .as_ref()- .map(|p| p.connected_integrations.clone())- .unwrap_or_default()- }- }- };- let allowlist: Vec<&crate::agent::prompts::ConnectedIntegration> =- live_integrations.iter().collect();- let connected_slugs: Vec<String> = allowlist- .iter()- .filter(|ci| ci.connected)- .map(|ci| ci.toolkit.clone())- .collect();-- tracing::debug!(- target: "spawn_subagent",- toolkit = ?toolkit_override,- allowlist_count = allowlist.len(),- connected_count = connected_slugs.len(),- connected = ?connected_slugs,- "[spawn_subagent] integrations_agent gate: validating toolkit"- );-- match toolkit_override.as_deref() {- None => {- return Ok(ToolResult::error(format!(- "spawn_subagent(integrations_agent): the `toolkit` argument is required. \- Pass one of the currently-connected toolkits: [{}]. \- See the Delegation Guide in your system prompt for which toolkit \- matches each task.",- connected_slugs.join(", ")- )));- }- Some(tk) => {- let entry = allowlist- .iter()- .find(|ci| ci.toolkit.eq_ignore_ascii_case(tk));- match entry {- None => {- // Toolkit isn't even in the backend allowlist.- return Ok(ToolResult::error(format!(- "spawn_subagent(integrations_agent): toolkit '{tk}' is not in \- the backend allowlist. Valid toolkits: [{}]. Check the \- Delegation Guide in your system prompt for the exact slug.",- allowlist- .iter()- .map(|ci| ci.toolkit.as_str())- .collect::<Vec<_>>()- .join(", ")- )));- }- Some(ci) if !ci.connected => {- // Toolkit exists in the allowlist but isn't connected.- // This is NOT a tool error — it's an expected condition- // the orchestrator should communicate to the user. We- // return `ToolResult::success` so:- // 1. The agent loop doesn't prepend "Error: " to- // the result text (which would bias the model- // toward defensive failure language).- // 2. The web channel emits `success: true` on the- // `tool_result` socket event, so the frontend- // doesn't render this as a failed tool call.- // The model still reads the explanation and produces- // an appropriate user-facing response.- //- // Split (#2365) into 4 cases driven by the upstream- // status field on the most-informative connection- // row, instead of the legacy generic- // "not authorized yet" copy. Before this split,- // an OAuth-in-progress / expired / failed Gmail- // surfaced the same "you need to connect Gmail"- // message — which Settings UI contradicted (it- // shows the connection as initiated/expired), so- // users concluded the agent was confused.- tracing::debug!(- target: "spawn_subagent",- toolkit = %ci.toolkit,- non_active_status = ?ci.non_active_status,- "[spawn_subagent] integrations_agent gate: toolkit not connected — emitting status-specific message"- );- let message = describe_unconnected_state(- &ci.toolkit,- ci.non_active_status.as_deref(),- );- return Ok(ToolResult::success(message));- }- Some(_) => {- tracing::debug!(- target: "spawn_subagent",- toolkit = %tk,- "[spawn_subagent] integrations_agent gate: toolkit connected, proceeding with spawn"- );- }- }- }- }- }-// Input, registry, allowlist, and integration validation are safe to// perform without a live run. A valid spawn must still fail closed// unless its typed harness parent carries authority and cancellation.