Skip to content

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

fix(composio): handle missing tool discovery gracefully

Steven Enamakel94bacacd6c5b
diff --git a/crates/openhuman-core/src/integrations/composio/client/direct.rs b/crates/openhuman-core/src/integrations/composio/client/direct.rs
index 6f72daf6e3..c9f7352dbe 100644
--- a/crates/openhuman-core/src/integrations/composio/client/direct.rs
+++ b/crates/openhuman-core/src/integrations/composio/client/direct.rs
@@ -1,15 +1,14 @@
-//! Direct-mode response reshapers: `direct_list_connections`, and `direct_list_tools`. Mirror the
-//! backend-proxied [`super::connections::ComposioClient`] methods but call
-//! Composio's v3 API directly (via a bound [`crate::tools::DirectComposioClient`])
-//! and reshape the v3 response into the same envelope types, so downstream
-//! callers in `ops.rs` / `tools.rs` don't have to branch on mode.
+//! Direct-mode response reshapers: `direct_list_connections`, and `direct_list_tools`.
+//! Call Composio's v3 API directly (via a bound [`crate::tools::DirectComposioClient`])
+//! and reshape the v3 response into the canonical envelope types, so downstream
+//! callers don't have to branch on mode.
use std::sync::Arc;
use super::super::direct_auth;
use super::super::types::{ComposioConnection, ComposioConnectionsResponse, ComposioToolsResponse};
-/// Direct-mode counterpart to [`ComposioClient::list_connections`].
+/// Direct-mode connection listing.
///
/// Calls Composio v3 `/connected_accounts` (via
/// [`crate::tools::DirectComposioClient::list_connected_accounts`])
@@ -95,7 +94,7 @@ pub async fn direct_list_connections(
Ok(ComposioConnectionsResponse { connections })
}
-/// Direct-mode counterpart to [`ComposioClient::list_tools`]. Calls
+/// Direct-mode tool listing. Calls
/// Composio v3 `/tools?toolkits=<csv>&tags=<a>&tags=<b>` via
/// [`crate::tools::DirectComposioClient::list_tool_schemas_v3`] and
/// reshapes each item into the same [`ComposioToolSchema`] envelope the
diff --git a/crates/openhuman-core/src/integrations/composio/client/factory.rs b/crates/openhuman-core/src/integrations/composio/client/factory.rs
index 0f96421fef..ce781c0ea1 100644
--- a/crates/openhuman-core/src/integrations/composio/client/factory.rs
+++ b/crates/openhuman-core/src/integrations/composio/client/factory.rs
@@ -51,15 +51,13 @@ impl ComposioRoute {
}
pub(crate) fn create_direct_client_for_api_key(
- config: &crate::config::Config,
api_key: &str,
) -> anyhow::Result<Arc<DirectComposioClient>> {
- direct_client(api_key, config.composio.entity_id.as_str(), None)
+ direct_client(api_key, None)
}
fn direct_client(
api_key: &str,
- entity_id: &str,
base_urls: Option<&crate::config::ComposioDirectBaseUrls>,
) -> anyhow::Result<Arc<DirectComposioClient>> {
let api_key = api_key.trim();
@@ -70,7 +68,6 @@ fn direct_client(
if let Some(urls) = base_urls {
let client = DirectComposioClient::new_with_base_urls(
api_key,
- Some(entity_id),
urls.v2.clone(),
urls.v3.clone(),
)?;
@@ -81,17 +78,12 @@ fn direct_client(
std::env::var("OPENHUMAN_COMPOSIO_DIRECT_BASE_V2").ok(),
std::env::var("OPENHUMAN_COMPOSIO_DIRECT_BASE_V3").ok(),
) {
- (Some(base_v2), Some(base_v3)) => DirectComposioClient::new_with_base_urls_for_loopback(
- api_key,
- Some(entity_id),
- base_v2,
- base_v3,
- )
+ (Some(base_v2), Some(base_v3)) => DirectComposioClient::new_with_base_urls_for_loopback(api_key, base_v2, base_v3)
.map_err(|e| anyhow::anyhow!("invalid debug composio direct loopback base override: {e}"))?,
- _ => DirectComposioClient::new(api_key, Some(entity_id)),
+ _ => DirectComposioClient::new(api_key),
};
#[cfg(not(debug_assertions))]
- let client = DirectComposioClient::new(api_key, Some(entity_id));
+ let client = DirectComposioClient::new(api_key);
Ok(Arc::new(client))
}
@@ -115,7 +107,7 @@ fn direct_client(
/// in `config.toml` fails loud instead of silently downgrading.
pub fn resolve_composio_route(config: &crate::config::Config) -> anyhow::Result<ComposioRoute> {
if let Some(pinned) = config.composio.host_credential.as_ref() {
- let client = direct_client(pinned.api_key(), pinned.entity(), pinned.direct_base_urls())?;
+ let client = direct_client(pinned.api_key(), pinned.direct_base_urls())?;
tracing::debug!("[composio-factory] resolved host-pinned direct variant (key redacted)");
return Ok(ComposioRoute::Direct(client));
}
@@ -158,7 +150,7 @@ pub fn resolve_composio_route(config: &crate::config::Config) -> anyhow::Result<
)
})?;
- let client = create_direct_client_for_api_key(config, &api_key)?;
+ let client = create_direct_client_for_api_key(&api_key)?;
tracing::debug!(
key_len = api_key.len(),
"[composio-factory] resolved direct variant (key redacted)"
diff --git a/crates/openhuman-core/src/integrations/composio/tools/direct/discovery.rs b/crates/openhuman-core/src/integrations/composio/tools/direct/discovery.rs
index 86f200f5c1..9f994e1fe6 100644
--- a/crates/openhuman-core/src/integrations/composio/tools/direct/discovery.rs
+++ b/crates/openhuman-core/src/integrations/composio/tools/direct/discovery.rs
@@ -12,8 +12,7 @@ impl DirectComposioClient {
/// listing used by [`Self::list_tool_schemas_v3`].
///
/// `toolkits` is sent as a single comma-joined `toolkits=` param (the
- /// legacy plural the v3 backend tolerates; cf. `list_actions_v3` which
- /// sends both the plural and `toolkit_slug` singular forms). `tags` is
+ /// legacy plural the v3 backend tolerates). `tags` is
/// encoded as **repeated** `tags=` params (`tags=a&tags=b`) — the shape
/// Composio v3 `/tools` documents for tag filtering ("can be specified
/// multiple times"), NOT the comma-joined form the backend proxy uses.
@@ -21,7 +20,7 @@ impl DirectComposioClient {
/// no `tags` params (treated as no filter).
///
/// Pure (no I/O) so the param shape is unit-testable without a live
- /// HTTP round trip — mirrors [`Self::build_execute_action_v3_request`].
+ /// HTTP round trip.
pub(super) fn build_list_tool_schemas_v3_query(
toolkits: &[&str],
tags: Option<&[&str]>,
@@ -55,12 +54,8 @@ impl DirectComposioClient {
/// List v3 tool definitions for one or more toolkits, preserving the
/// raw `input_parameters` JSON schema each action carries.
///
- /// Sibling of [`Self::list_actions`] but kept distinct because
- /// `list_actions` flattens to `Vec<ComposioAction>` (no parameters)
- /// for the legacy agent-discovery shape, whereas
- /// `composio_list_tools`'s direct-mode branch needs the full schema
- /// so the LLM agent can supply valid arguments without a separate
- /// round trip.
+ /// Preserves the full schema so the LLM agent can supply valid arguments
+ /// without a separate round trip.
///
/// `toolkits` may contain one or many slugs; when non-empty they are
/// sent as a comma-separated `toolkits=` filter to constrain the v3
@@ -71,8 +66,7 @@ impl DirectComposioClient {
/// `tags` narrows the result by Composio action tag (OR semantics —
/// multiple tags broaden the result). This is the direct-mode (BYO
/// key) counterpart to the backend proxy's `tags` query param wired
- /// in [`crate::integrations::composio::client::ComposioClient::list_tools`];
- /// without it a self-key user's `composio_list_tools(..., tags)`
+ /// in the connector module's proxy route; without it a self-key user's `composio_list_tools(..., tags)`
/// request would silently drop the tag filter. Blank/empty `tags`
/// are treated as no filter.
pub(crate) async fn list_tool_schemas_v3(