Skip to content

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

fix(composio): correct tool listing and connection handling

Steven Enamakel443724fd83f8
diff --git a/crates/openhuman-core/src/integrations/composio/tools/connect.rs b/crates/openhuman-core/src/integrations/composio/tools/connect.rs
index fcab57deb8..75f6a9a8ff 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/connect.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/connect.rs
@@ -13,7 +13,9 @@ use super::redact::redact_composio_outcome;
use crate::config::Config;
use tinytools::{PermissionLevel, Tool, ToolCategory, ToolResult};
-use super::super::client::{create_composio_client, direct_list_connections, ComposioClientKind};
+use super::super::client::{direct_list_connections, resolve_composio_route, ComposioRoute};
+use super::super::module_client::{self as connectors, methods};
+use super::super::types::{ComposioConnectionsResponse, ComposioToolkitsResponse};
// ── composio_connect (inline approval card, #3993) ──────────────────
@@ -96,11 +98,17 @@ pub(super) async fn connection_is_active(config: &Config, toolkit: &str) -> anyh
.iter()
.any(|c| c.is_active() && c.normalized_toolkit().eq_ignore_ascii_case(toolkit))
};
- match create_composio_client(config)? {
- ComposioClientKind::Backend(client) => {
- Ok(active_match(&client.list_connections().await?.connections))
+ match resolve_composio_route(config)? {
+ ComposioRoute::Backend => {
+ let resp = connectors::call_bare::<ComposioConnectionsResponse>(
+ config,
+ methods::LIST_CONNECTIONS,
+ )
+ .await
+ .map_err(anyhow::Error::msg)?;
+ Ok(active_match(&resp.connections))
}
- ComposioClientKind::Direct(direct) => Ok(active_match(
+ ComposioRoute::Direct(direct) => Ok(active_match(
&direct_list_connections(&direct).await?.connections,
)),
}
@@ -226,9 +234,14 @@ impl ComposioConnectTool {
// (#3993). This grounds the answer: a backend-allowlisted toolkit gets
// a card; a genuinely unsupported one gets a clear, listed refusal
// instead of a card that would fail on Connect.
- match create_composio_client(&live_config) {
- Ok(ComposioClientKind::Backend(client)) => {
- if let Ok(resp) = client.list_toolkits().await {
+ match resolve_composio_route(&live_config) {
+ Ok(ComposioRoute::Backend) => {
+ if let Ok(resp) = connectors::call_bare::<ComposioToolkitsResponse>(
+ &live_config,
+ methods::LIST_TOOLKITS,
+ )
+ .await
+ {
// Empty allowlist = backend predates the catalog / unknown;
// don't block — let the OAuth handoff report support.
if !resp.toolkits.is_empty()
@@ -246,7 +259,7 @@ impl ComposioConnectTool {
}
}
}
- Ok(ComposioClientKind::Direct(_)) => {
+ Ok(ComposioRoute::Direct(_)) => {
// Personal-tenant (direct) mode performs OAuth at app.composio.dev,
// not via the backend handoff the card drives — so an inline card
// can't complete it. Point the user to Settings instead.
diff --git a/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs b/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs
index d96005cab3..3aef9e113c 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/list_connections.rs
@@ -10,10 +10,12 @@ use super::redact::{redact_and_report, redact_composio_outcome};
use crate::config::Config;
use tinytools::{PermissionLevel, Tool, ToolCategory, ToolResult};
-use super::super::client::{create_composio_client, direct_list_connections, ComposioClientKind};
+use super::super::client::{direct_list_connections, resolve_composio_route, ComposioRoute};
+use super::super::module_client::{self as connectors, methods};
+use super::super::types::ComposioConnectionsResponse;
pub struct ComposioListConnectionsTool {
- /// Held instead of a pre-baked `ComposioClient` so the
+ /// Held instead of a pre-resolved route so the
/// [`crate::config::ComposioConfig::mode`] toggle is
/// honoured on every call (#1710).
config: Arc<Config>,
@@ -82,19 +84,21 @@ impl ComposioListConnectionsTool {
);
}
};
- let mut resp = match create_composio_client(&live_config) {
- Ok(ComposioClientKind::Backend(client)) => {
+ let mut resp = match resolve_composio_route(&live_config) {
+ Ok(ComposioRoute::Backend) => {
tracing::debug!("[composio] list_connections.execute: backend variant");
- match client
- .list_connections()
- .await
- .map_err(|e| anyhow::anyhow!("composio_list_connections (backend) failed: {e}"))
+ match connectors::call_bare::<ComposioConnectionsResponse>(
+ &live_config,
+ methods::LIST_CONNECTIONS,
+ )
+ .await
+ .map_err(|e| anyhow::anyhow!("composio_list_connections (backend) failed: {e}"))
{
Ok(resp) => resp,
Err(e) => return (live_config, Err(e)),
}
}
- Ok(ComposioClientKind::Direct(direct)) => {
+ Ok(ComposioRoute::Direct(direct)) => {
tracing::debug!("[composio-direct] list_connections.execute: direct variant");
match direct_list_connections(&direct).await.map_err(|e| {
// [#1166 / Sentry TAURI-RUST-X9] Symmetric error
diff --git a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs
index f530829f49..fa3514ae59 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/list_tools.rs
@@ -11,17 +11,20 @@ use super::redact::redact_composio_outcome;
use crate::config::Config;
use tinytools::{PermissionLevel, Tool, ToolCallOptions, ToolCategory, ToolResult};
-use super::super::client::{create_composio_client, ComposioClientKind};
-use super::super::types::ComposioToolsResponse;
+use super::super::client::{resolve_composio_route, ComposioRoute};
+use super::super::module_client::{self as connectors, methods};
+use super::super::types::{
+ ComposioConnectionsResponse, ComposioListToolsRequest, ComposioToolsResponse,
+};
use super::visibility::{
empty_uncurated_toolkits_message, filter_list_tools_response, normalized_scope_toolkits,
render_tools_markdown, retain_connected_tools,
};
pub struct ComposioListToolsTool {
- /// Held instead of a pre-baked `ComposioClient` so the
+ /// Held instead of a pre-resolved route so the
/// [`crate::config::ComposioConfig::mode`] toggle is
- /// honoured on every call. Resolving the client per call mirrors
+ /// honoured on every call. Resolving the route per call mirrors
/// [`crate::integrations::composio::ops::composio_execute`] and avoids
/// the staged-routing bug (#1710) where a long-lived backend client
/// would survive a user switch into `direct` mode.
@@ -166,12 +169,11 @@ impl ComposioListToolsTool {
);
}
};
- let client = match create_composio_client(&live_config) {
- Ok(ComposioClientKind::Backend(client)) => {
+ match resolve_composio_route(&live_config) {
+ Ok(ComposioRoute::Backend) => {
tracing::debug!("[composio] list_tools.execute: backend variant");
- client
}
- Ok(ComposioClientKind::Direct(_)) => {
+ Ok(ComposioRoute::Direct(_)) => {
tracing::info!(
"[composio-direct] list_tools.execute: direct mode active — \
returning empty tools list. Discovery is delegated to the user's \
@@ -197,9 +199,21 @@ impl ComposioListToolsTool {
}
};
- let outcome = match client
- .list_tools(toolkits.as_deref(), tags.as_deref())
- .await
+ // The module owns the proxy route's query construction; the scope
+ // preference is applied host-side below (`filter_list_tools_response`)
+ // because it is stored where only the host can read it, so the
+ // module is asked not to apply its own defaults on top.
+ let request = ComposioListToolsRequest {
+ toolkits: toolkits.clone().unwrap_or_default(),
+ tags: tags.clone().unwrap_or_default(),
+ apply_user_scopes: false,
+ };
+ let outcome = match connectors::call::<_, ComposioToolsResponse>(
+ &live_config,
+ methods::LIST_TOOLS,
+ request,
+ )
+ .await
{
Ok(mut resp) => {
filter_list_tools_response(&live_config, &mut resp).await;
@@ -210,7 +224,12 @@ impl ComposioListToolsTool {
// account. Mirrors the same status allowlist used by
// composio_list_connections so this view and the
// prompt's Delegation Guide stay in sync.
- match client.list_connections().await {
+ match connectors::call_bare::<ComposioConnectionsResponse>(
+ &live_config,
+ methods::LIST_CONNECTIONS,
+ )
+ .await
+ {
Ok(conns) => {
let connected: HashSet<String> = conns
.connections