Skip to content

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

feat(composio): resolve connected toolkits through a host provider

Steven Enamakel92fca1ef6050
diff --git a/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs b/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
index 7fc3603643..0dfc570a8e 100644
--- a/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_connection_reads.rs
@@ -5,6 +5,19 @@ use serde_json::Value;
pub(crate) struct FlowsConnectionProvider;
+#[async_trait]
+impl crate::integrations::composio::builder_tools::ConnectableToolkitProvider
+ for FlowsConnectionProvider
+{
+ async fn connected(
+ &self,
+ dispatch: &crate::core::runtime::DispatchCtx,
+ config: &crate::config::Config,
+ ) -> Vec<String> {
+ crate::flows::ops::connected_toolkits(dispatch, config).await
+ }
+}
+
#[async_trait]
impl crate::integrations::composio::builder_tools::FlowConnectionProvider
for FlowsConnectionProvider
diff --git a/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs b/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs
index c0d5d12feb..fc384d625c 100644
--- a/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs
+++ b/crates/openhuman-core/src/integrations/composio/builder_tools/connection_reads.rs
@@ -18,11 +18,22 @@ pub trait FlowConnectionProvider: Send + Sync {
) -> Result<Vec<Value>, String>;
}
+/// Host source for the workflow editor's agent-ready toolkit list.
+#[async_trait]
+pub trait ConnectableToolkitProvider: Send + Sync {
+ async fn connected(
+ &self,
+ dispatch: &crate::core::runtime::DispatchCtx,
+ config: &Config,
+ ) -> Vec<String>;
+}
+
/// `list_connectable_toolkits`: read-only list of the Composio toolkits the
/// builder can wire, each tagged connected/unconnected — so the agent can steer
/// toolkit choice toward what's already connected (audit Phase 5, item 19).
pub struct ListConnectableToolkitsTool {
config: Arc<Config>,
+ provider: Arc<dyn ConnectableToolkitProvider>,
}
/// Read-only mixed connection picker backed by a host supplied provider.
@@ -41,7 +52,16 @@ impl ListFlowConnectionsTool {
impl Tool for ListFlowConnectionsTool {
fn name(&self) -> &str { "list_flow_connections" }
fn description(&self) -> &str {
- "List the connection sources a flow node's `connection_ref` can attach to. Read-only; returns non-secret metadata only."
+ "List the connection sources a flow node's `connection_ref` can attach to: \
+ Composio connected accounts and named HTTP credentials. Read-only; \
+ returns only non-secret metadata — ids, display labels, kind, and \
+ `toolkit`/`scheme` (never any secret). Each \
+ Composio entry also carries `platform_user_id` — the connected \
+ account's own member id (e.g. Slack `U123ABC`) — use it to wire a \
+ self-targeted action like 'DM me' to that account instead of a \
+ public channel. Use the `connection_ref` values verbatim on \
+ tool_call / http_request nodes so the generated flow carries valid \
+ connections."
}
fn parameters_schema(&self) -> Value {
json!({ "type": "object", "properties": {}, "additionalProperties": false })
@@ -58,16 +78,21 @@ impl Tool for ListFlowConnectionsTool {
tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
let dispatch = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);
+ tracing::debug!(target: "flows", "[flows] list_flow_connections: enumerating connection refs (read-only)");
match self.provider.list(&dispatch, &self.config).await {
- Ok(connections) => Ok(ToolResult::success(serde_json::to_string_pretty(&json!({ "connections": connections }))?)),
- Err(error) => Ok(ToolResult::error(format!("Failed to list flow connections: {error}"))),
+ Ok(connections) => Ok(ToolResult::success(serde_json::to_string_pretty(
+ &json!({ "connections": connections }),
+ )?)),
+ Err(error) => Ok(ToolResult::error(format!(
+ "Failed to list flow connections: {error}"
+ ))),
}
}
}
impl ListConnectableToolkitsTool {
- pub fn new(config: Arc<Config>) -> Self {
- Self { config }
+ pub fn new(config: Arc<Config>, provider: Arc<dyn ConnectableToolkitProvider>) -> Self {
+ Self { config, provider }
}
}
@@ -107,16 +132,12 @@ impl Tool for ListConnectableToolkitsTool {
_options: ToolCallOptions,
tool_context: Option<&dyn ToolRunContext>,
) -> anyhow::Result<ToolResult> {
- let _ctx = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);
+ let ctx = crate::agent::tinyagents::host::run_context::dispatch_ctx_for_tool(tool_context);
// The agent-ready list is the connector module's (`GetVocabulary`),
// read through the host's curated snapshot.
use crate::integrations::composio::contract::agent_ready_toolkits;
tracing::debug!(target: "flows", "[flows] list_connectable_toolkits: listing toolkits + connected state (read-only) via the memory contract");
- let connected = crate::integrations::composio::flow_gate::connected_toolkit_slugs(&self.config)
- .await
- .unwrap_or_default()
- .into_iter()
- .collect::<std::collections::HashSet<_>>();
+ let connected = self.provider.connected(&ctx, &self.config).await;
let toolkits: Vec<Value> = agent_ready_toolkits()
.into_iter()
.map(|tk| {
diff --git a/crates/openhuman-core/src/integrations/composio/builder_tools/mod.rs b/crates/openhuman-core/src/integrations/composio/builder_tools/mod.rs
index a3c8de0352..79b3ab5334 100644
--- a/crates/openhuman-core/src/integrations/composio/builder_tools/mod.rs
+++ b/crates/openhuman-core/src/integrations/composio/builder_tools/mod.rs
@@ -14,7 +14,7 @@ mod tool_contract;
pub(crate) use catalog_search::search_live_catalog;
pub use catalog_search::SearchToolCatalogTool;
-pub use connection_reads::{FlowConnectionProvider, ListConnectableToolkitsTool, ListFlowConnectionsTool};
+pub use connection_reads::{ConnectableToolkitProvider, FlowConnectionProvider, ListConnectableToolkitsTool, ListFlowConnectionsTool};
pub use tool_contract::{GetToolContractTool, GetToolOutputSampleTool};
#[cfg(test)]
diff --git a/crates/openhuman-core/src/integrations/composio/flow_backend.rs b/crates/openhuman-core/src/integrations/composio/flow_backend.rs
index 70fce94aa5..2661012741 100644
--- a/crates/openhuman-core/src/integrations/composio/flow_backend.rs
+++ b/crates/openhuman-core/src/integrations/composio/flow_backend.rs
@@ -83,6 +83,15 @@ pub(crate) async fn invoke(
};
let connection_id = conn.and_then(crate::integrations::composio::flow_gate::composio_connection_id);
+ let resolved_account = match connection_id {
+ Some(id) => Some((id, crate::integrations::composio::flow_gate::resolve_composio_account(&live, id).await)),
+ None => None,
+ };
+ match &resolved_account {
+ Some((id, Some((toolkit, _)))) => tracing::info!(target: "flows", %slug, connection_id = %id, %toolkit, mode = live.composio.mode.as_str(), "[flows] tool_call: executing against the resolved connected account"),
+ Some((id, None)) => tracing::warn!(target: "flows", %slug, connection_id = %id, mode = live.composio.mode.as_str(), "[flows] tool_call: connection_ref connection_id not found among the user's live connected accounts (stale cache or foreign id) — forwarding the exact id so the provider can reject it rather than falling back to an ambient account"),
+ None => tracing::debug!(target: "flows", %slug, mode = live.composio.mode.as_str(), "[flows] tool_call: no connection_ref — using the ambient signed-in account"),
+ }
let response = execute_for_connection(&live, slug, (!args.is_null()).then_some(args), connection_id)
.await
.and_then(|result| crate::integrations::composio::flow_gate::reject_unsuccessful_composio_response(slug, result).map_err(|error| error.to_string()))