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 connection fields gracefully

Steven Enamakel8614c7b66cc5
diff --git a/crates/openhuman-core/src/integrations/composio/ops/connections.rs b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
index 601e5138e2..8a08b22750 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/connections.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/connections.rs
@@ -255,6 +255,35 @@ pub async fn composio_delete_connection(
))
}
+/// The ids of every active connection of `toolkit` (matched
+/// case-insensitively), through the connector module's `ListConnections`.
+///
+/// # Errors
+///
+/// The connector call fails.
+pub async fn active_connection_ids(config: &Config, toolkit: &str) -> OpResult<Vec<String>> {
+ let toolkit = toolkit.trim().to_ascii_lowercase();
+ let resp =
+ connectors::call_bare::<ComposioConnectionsResponse>(config, methods::LIST_CONNECTIONS)
+ .await
+ .map_err(|error| {
+ report_composio_op_error("active_connection_ids", &anyhow::anyhow!("{error}"));
+ format!("[composio] list_connections failed: {error}")
+ })?;
+ let ids: Vec<String> = resp
+ .connections
+ .into_iter()
+ .filter(|c| c.is_active() && c.normalized_toolkit() == toolkit)
+ .map(|c| c.id)
+ .collect();
+ tracing::debug!(
+ toolkit = %toolkit,
+ active = ids.len(),
+ "[composio] active_connection_ids"
+ );
+ Ok(ids)
+}
+
/// Look up the toolkit slug for an existing connection.
pub(super) async fn resolve_toolkit_for_connection(
config: &Config,