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(composio): replace create_composio_client with resolve_composio_route
Steven Enamakel098479ea0716
diff --git a/crates/openhuman-core/src/agent/session_host/turn/tools.rs b/crates/openhuman-core/src/agent/session_host/turn/tools.rsindex 0d69e33959..9056c2788b 100644--- a/crates/openhuman-core/src/agent/session_host/turn/tools.rs+++ b/crates/openhuman-core/src/agent/session_host/turn/tools.rs@@ -131,7 +131,7 @@ impl OpenHumanSessionHost {/// **No session-scoped Composio client is cached on the agent any/// more (#1710 Wave 2)**. Every downstream caller that needs to/// dispatch a Composio action now resolves a fresh client via- /// [`crate::integrations::composio::client::create_composio_client`]+ /// [`crate::integrations::composio::client::resolve_composio_route`]/// at call time so the live `composio.mode` toggle is honoured/// without rebuilding the session — see `ComposioActionTool`,/// `ProviderContext::execute`, the 5 migrated agent tools indiff --git a/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs b/crates/openhuman-core/src/agent/subagent_host/ops/provider.rsindex e26a629a01..12ed4aa43a 100644--- a/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs+++ b/crates/openhuman-core/src/agent/subagent_host/ops/provider.rs@@ -95,12 +95,12 @@ pub(crate) fn resolve_subagent_source(/// client (BYO Composio API key). The resolved client is dropped/// immediately — this is purely a "signed-in vs not" check used by the/// spawn-time refresh path. Per-action dispatch resolves a fresh client-/// elsewhere via [`create_composio_client`] so the live `composio.mode`+/// elsewhere via [`resolve_composio_route`] so the live `composio.mode`/// toggle keeps winning.////// Extracted as a free function so the regression suite can exercise/// the same probe the runner uses without spinning up the full/// `run_typed_mode` plumbing.pub(crate) fn user_is_signed_in_to_composio(config: &crate::config::Config) -> bool {- crate::integrations::composio::client::create_composio_client(config).is_ok()+ crate::integrations::composio::client::resolve_composio_route(config).is_ok()}diff --git a/crates/openhuman-core/src/integrations/composio/action_tool.rs b/crates/openhuman-core/src/integrations/composio/action_tool.rsindex ff272edcb7..28c28715c6 100644--- a/crates/openhuman-core/src/integrations/composio/action_tool.rs+++ b/crates/openhuman-core/src/integrations/composio/action_tool.rs@@ -17,12 +17,12 @@//! run. Those instances have no spawn-time config to anchor to and resolve//! the live config through the core's read path instead.//!-//! Rather than baking a `ComposioClient` at construction time+//! Rather than baking a pre-resolved route at construction time//! (which would silently bypass a mid-session//! [`crate::config::ComposioConfig::mode`] toggle — see//! issue #1710), each tool keeps an [`Arc<Config>`] and resolves the//! client per call through-//! [`create_composio_client`] so a user flip from+//! [`resolve_composio_route`] so a user flip from//! `mode = "backend"` to `mode = "direct"` is honoured on the next//! tool invocation without restarting the session. Mirrors the agent-//! tool migration in@@ -43,18 +43,18 @@ use tinytools::{PermissionLevel, Tool, ToolCategory, ToolResult};/// A single Composio action exposed as a first-class tool.pub struct ComposioActionTool {- /// Held instead of a pre-baked [`super::client::ComposioClient`] so+ /// Held instead of a pre-baked a pre-resolved route so/// the [`crate::config::ComposioConfig::mode`] toggle is/// honoured on every invocation.///- /// Pre-fix this field was `client: ComposioClient`, which captured+ /// Pre-fix this field was `client: ComposioClient` (the since-removed in-process client), which captured/// the backend-bound handle at sub-agent spawn time. Toggling/// `composio.mode = "direct"` mid-session invalidated other caches/// but left these per-action tools still routing through/// `staging-api.tinyhumans.ai/agent-integrations/composio/execute`/// — silently bypassing the direct-mode user's personal Composio/// tenant. Resolving the client per call via- /// [`create_composio_client`] keeps dispatch in lockstep with the+ /// [`resolve_composio_route`] keeps dispatch in lockstep with the/// live config, matching/// [`super::tools::ComposioExecuteTool`]. See issue #1710.///diff --git a/crates/openhuman-core/src/memory/sync/composio/bus/connection_created_subscriber.rs b/crates/openhuman-core/src/memory/sync/composio/bus/connection_created_subscriber.rsindex 2b10a47810..3dd8e99321 100644--- a/crates/openhuman-core/src/memory/sync/composio/bus/connection_created_subscriber.rs+++ b/crates/openhuman-core/src/memory/sync/composio/bus/connection_created_subscriber.rs@@ -11,18 +11,20 @@ use tinybus::EventHandler;use crate::config::rpc as config_rpc;use crate::core::events::DomainEvent;-use crate::integrations::composio::client::{- create_composio_client, ComposioClient, ComposioClientKind,-};+use crate::integrations::composio::client::{resolve_composio_route, ComposioRoute};+use crate::integrations::composio::module_client::{self as connectors, methods};+use crate::integrations::composio::types::ComposioConnectionsResponse;use crate::integrations::composio::ops;use crate::integrations::composio::FetchConnectedIntegrationsStatus;-/// A backend-tenant Composio client for one toolkit.+/// The live config for one toolkit's connection-readiness probe, once it is+/// known to resolve to the backend tenant.////// This was `ProviderContextExt::backend_client`, an extension trait on the/// engine's `ProviderContext` that existed for a single caller — the/// connection-readiness probe below. With the context gone the trait had-/// nothing to extend, so the resolution lives here instead.+/// nothing to extend, so the resolution lives here instead. The probe itself+/// is a connector-module `ListConnections` call made with this config.////// The config is reloaded rather than taken from the snapshot on purpose: the/// OAuth completion this subscriber reacts to may have written credentials@@ -30,19 +32,19 @@ use crate::integrations::composio::FetchConnectedIntegrationsStatus;/// next call. Direct mode is a hard error rather than a silent fallback — the/// helpers behind this were written against the backend tenant, and routing/// them through the wrong one is worse than refusing (#1710).-async fn backend_composio_client(+async fn backend_composio_config(config: &crate::config::Config,toolkit: &str,-) -> anyhow::Result<ComposioClient> {+) -> anyhow::Result<crate::config::Config> {let live_config =crate::config::rpc::reload_config_from_paths(&config.config_path, &config.workspace_dir).await.map_err(|e| {anyhow::anyhow!("composio backend client: failed to reload live config: {e}")})?;- match create_composio_client(&live_config)? {- ComposioClientKind::Backend(client) => Ok(client),- ComposioClientKind::Direct(_) => Err(anyhow::anyhow!(+ match resolve_composio_route(&live_config)? {+ ComposioRoute::Backend => Ok(live_config),+ ComposioRoute::Direct(_) => Err(anyhow::anyhow!("composio direct mode is not supported on this helper path; toolkit={toolkit}")),}@@ -222,7 +224,7 @@ impl EventHandler<DomainEvent> for ComposioConnectionCreatedSubscriber {// host's own factory, so ask it directly rather than through a// context object built only to be handed back over the bus.let config = Arc::new(config);- if create_composio_client(&config).is_err() {+ if resolve_composio_route(&config).is_err() {tracing::debug!(toolkit = %toolkit,"[composio:bus] no composio client (not signed in?), skipping hook"@@ -247,7 +249,7 @@ impl EventHandler<DomainEvent> for ComposioConnectionCreatedSubscriber {// `wait_for_connection_active` is a backend-only metadata// probe (`list_connections`). Resolve a backend- // `ComposioClient` from the live config for it; direct-mode+ // live config for it; direct-mode// users surface a clear error here rather than silently// routing through the wrong tenant (#1710).// Was `ctx.backend_client()`, a host extension trait bolted onto@@ -255,7 +257,7 @@ impl EventHandler<DomainEvent> for ComposioConnectionCreatedSubscriber {// the resolution lives at its only call site: reload the live config// (the OAuth completion being reacted to may have written// credentials since the snapshot) and require the backend tenant.- let backend_client = match backend_composio_client(&config, &toolkit).await {+ let backend_config = match backend_composio_config(&config, &toolkit).await {Ok(c) => c,Err(e) => {tracing::debug!(@@ -266,7 +268,7 @@ impl EventHandler<DomainEvent> for ComposioConnectionCreatedSubscriber {return;}};- match wait_for_connection_active(&backend_client, &connection_id).await {+ match wait_for_connection_active(&backend_config, &connection_id).await {Ok(status) => {tracing::info!(toolkit = %toolkit,@@ -548,7 +550,7 @@ pub(super) enum WaitError {/// On success returns the observed status string. On timeout returns/// the last status we saw (helpful for "stuck in INITIATED" debugging).async fn wait_for_connection_active(- client: &ComposioClient,+ config: &crate::config::Config,connection_id: &str,) -> Result<String, WaitError> {let started = std::time::Instant::now();@@ -556,7 +558,9 @@ async fn wait_for_connection_active(let mut last_status: Option<String> = None;loop {- match client.list_connections().await {+ match connectors::call_bare::<ComposioConnectionsResponse>(config, methods::LIST_CONNECTIONS)+ .await+ {Ok(resp) => {if let Some(conn) = resp.connections.into_iter().find(|c| c.id == connection_id) {if conn.is_active() {diff --git a/crates/openhuman-core/src/memory/sync/composio/providers/slack/rpc.rs b/crates/openhuman-core/src/memory/sync/composio/providers/slack/rpc.rsindex 091ece8149..1dbaeb5c89 100644--- a/crates/openhuman-core/src/memory/sync/composio/providers/slack/rpc.rs+++ b/crates/openhuman-core/src/memory/sync/composio/providers/slack/rpc.rs@@ -38,8 +38,9 @@ use serde::{Deserialize, Serialize};use crate::config::Config;use crate::core::Outcome;use crate::integrations::composio::client::{- create_composio_client, direct_list_connections, ComposioClientKind,+ direct_list_connections, resolve_composio_route, ComposioRoute,};+use crate::integrations::composio::module_client::{self as connectors, methods};use crate::integrations::composio::ops::run_sync_within_budget;use crate::integrations::composio::providers::SyncOutcome;use crate::integrations::composio::types::ComposioConnectionsResponse;@@ -71,14 +72,16 @@ pub struct SyncTriggerResponse {/// filtering, identical error wrapping, distinct log prefixes for/// debuggability.async fn list_slack_connections(config: &Config) -> Result<ComposioConnectionsResponse, String> {- let kind = create_composio_client(config)+ let kind = resolve_composio_route(config).map_err(|e| format!("[slack_ingest] list_connections: {e}"))?;match kind {- ComposioClientKind::Backend(client) => client- .list_connections()- .await- .map_err(|e| format!("[slack_ingest] list_connections (backend) failed: {e:#}")),- ComposioClientKind::Direct(direct) => direct_list_connections(&direct)+ ComposioRoute::Backend => connectors::call_bare::<ComposioConnectionsResponse>(+ config,+ methods::LIST_CONNECTIONS,+ )+ .await+ .map_err(|e| format!("[slack_ingest] list_connections (backend) failed: {e}")),+ ComposioRoute::Direct(direct) => direct_list_connections(&direct).await.map_err(|e| format!("[slack_ingest] list_connections (direct) failed: {e:#}")),}diff --git a/crates/openhuman-core/src/modules/memory_host.rs b/crates/openhuman-core/src/modules/memory_host.rsindex bdba8f38dc..0544b85b46 100644--- a/crates/openhuman-core/src/modules/memory_host.rs+++ b/crates/openhuman-core/src/modules/memory_host.rs@@ -187,17 +187,19 @@ struct ComposioCallbacks(Arc<Config>);impl ComposioCallbacks {async fn list_connections(&self) -> tinybus::Result<Vec<ComposioConnection>> {use crate::integrations::composio::client::{- create_composio_client, direct_list_connections, ComposioClientKind,+ direct_list_connections, resolve_composio_route, ComposioRoute,};+ use crate::integrations::composio::module_client::{self as connectors, methods};let config = self.live_config().await.map_err(method_error)?;- let response = match create_composio_client(&config)- .map_err(|e| method_error(format!("create_composio_client: {e:#}")))?+ let response = match resolve_composio_route(&config)+ .map_err(|e| method_error(format!("resolve_composio_route: {e:#}")))?{- ComposioClientKind::Backend(client) => client- .list_connections()- .await- .map_err(|e| method_error(format!("list_connections (backend): {e:#}")))?,- ComposioClientKind::Direct(direct) => {+ ComposioRoute::Backend => connectors::call_bare::<+ crate::integrations::composio::types::ComposioConnectionsResponse,+ >(&config, methods::LIST_CONNECTIONS)+ .await+ .map_err(|e| method_error(format!("list_connections (backend): {e}")))?,+ ComposioRoute::Direct(direct) => {direct_list_connections(&direct).await.map_err(|e| {// [#1166 / Sentry TAURI-RUST-X9] The v3 `/connected_accounts`// 401 shape has to reach the observability classifier, and it@@ -307,9 +309,9 @@ impl ComposioCallbacks {/// direct-mode user has no backend session, and testing for one would read/// as signed-out and skip them (#1710).async fn is_available(&self) -> tinybus::Result<bool> {- use crate::integrations::composio::client::create_composio_client;+ use crate::integrations::composio::client::resolve_composio_route;let config = self.live_config_or_installed().await;- Ok(create_composio_client(config.as_ref()).is_ok())+ Ok(resolve_composio_route(config.as_ref()).is_ok())}}diff --git a/crates/openhuman-core/src/security/credentials/ops/composio.rs b/crates/openhuman-core/src/security/credentials/ops/composio.rsindex 5be21bc2cd..9d0a64d9bd 100644--- a/crates/openhuman-core/src/security/credentials/ops/composio.rs+++ b/crates/openhuman-core/src/security/credentials/ops/composio.rs@@ -54,7 +54,7 @@ pub async fn store_composio_api_key(/// Read the user-provided Composio API key from the encrypted credential/// store. Returns `Ok(None)` when no key has been stored yet.///-/// Used by [`crate::integrations::composio::client::create_composio_client`]+/// Used by [`crate::integrations::composio::client::resolve_composio_route`]/// to decide whether direct mode can actually be activated.pub fn get_composio_api_key(config: &Config) -> Result<Option<String>, String> {let auth = AuthService::from_config(config);