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
fix(flows): honor selected Composio account\n
simple_naive811487fb768a
diff --git a/src/openhuman/flows/tinyflows/caps/ops.rs b/src/openhuman/flows/tinyflows/caps/ops.rsindex 140f8ca31f..e2210a78de 100644--- a/src/openhuman/flows/tinyflows/caps/ops.rs+++ b/src/openhuman/flows/tinyflows/caps/ops.rs@@ -380,18 +380,12 @@ pub(crate) async fn resolve_composio_account(/// connected set — and it still closes the case where an author hand-types/// an arbitrary/typo'd slug./// - **connection_ref**: `conn` (`"composio:<toolkit>:<connection_id>"`) is-/// now parsed and forwarded to `direct_execute` (Composio Direct mode).-/// Backend mode's `execute_tool` still has no per-call account-scoping-/// path — that's a backend API gap, not something this seam can close-/// alone — so under Backend mode, a `connection_ref` naming a SPECIFIC-/// connected account is NOT honored: the call executes against whatever-/// account happens to be the ambient signed-in session instead (E-m3),-/// which — when the flow author connected/expected a *different* account-/// for this action — means the action runs as the wrong identity, not a-/// graceful no-op. This proceeds rather than failing closed; it logs a-/// `warn!` naming both the requested and actually-used account so the-/// mismatch is at least visible in logs, but nothing currently blocks the-/// call. Documented backend-API-gap stub; see `composio_connection_id`.+/// parsed and forwarded in both modes: Direct passes it to Composio's+/// execute endpoint, while Backend includes it as `connectionId` in the+/// authenticated `/agent-integrations/composio/execute` request. Omitting a+/// ref deliberately keeps the ambient-account behavior. A supplied but+/// stale/foreign id is still forwarded exactly so the provider rejects it;+/// it must never degrade to the ambient account (fixes #5751 / E-m3)./// - **Trust gate**: invocation is also routed through the OpenHuman/// `ApprovalGate` (mirrors `tinyagents/middleware.rs::ApprovalSecurityMiddleware`)/// before dispatch, closing the Codex P1 finding that flow tool nodesdiff --git a/src/openhuman/flows/tinyflows/caps/tools/composio.rs b/src/openhuman/flows/tinyflows/caps/tools/composio.rsindex 87bc379e2b..91663f74e6 100644--- a/src/openhuman/flows/tinyflows/caps/tools/composio.rs+++ b/src/openhuman/flows/tinyflows/caps/tools/composio.rs@@ -27,12 +27,35 @@ use crate::openhuman::config::Config;use crate::openhuman::integrations::composio::client::{create_composio_client, direct_execute, ComposioClientKind,};+use crate::openhuman::integrations::composio::ComposioExecuteResponse;use crate::openhuman::security::GateDecision;/// Dispatches a Composio action slug through the tier, curation, preflight and/// approval gates.pub(crate) struct ComposioToolBackend;+/// Dispatches through the selected Composio mode while preserving the+/// workflow node's exact connected-account choice.+async fn execute_for_connection(+ kind: ComposioClientKind,+ slug: &str,+ args: Option<Value>,+ entity_id: &str,+ connection_id: Option<&str>,+) -> Result<ComposioExecuteResponse> {+ match kind {+ ComposioClientKind::Backend(client) => client+ .execute_tool_with_connection(slug, args, connection_id)+ .await+ .map_err(|e| EngineError::Capability(e.to_string())),+ ComposioClientKind::Direct(tool) => {+ direct_execute(&tool, slug, args, entity_id, connection_id)+ .await+ .map_err(|e| EngineError::Capability(e.to_string()))+ }+ }+}+#[async_trait]impl ToolBackend for ComposioToolBackend {fn name(&self) -> &'static str {@@ -182,75 +205,39 @@ impl ToolBackend for ComposioToolBackend {"[flows] tool_call: invoking composio tool");- let response = match kind {- ComposioClientKind::Backend(client) => {- if let Some((id, resolved)) = &resolved_account {- match resolved {- Some((toolkit, _label)) => tracing::warn!(- target: "flows",- %slug,- connection_id = %id,- %toolkit,- "[flows] tool_call: EXECUTING ON THE WRONG ACCOUNT — connection_ref \- names a specific connected account, but backend mode has no per-call \- account-scoping path yet, so this call runs against the AMBIENT \- signed-in session account instead of the one requested (E-m3, \- documented backend-API-gap stub, see caps.rs's OpenHumanTools doc). \- Proceeds rather than failing closed."- ),- None => tracing::warn!(- target: "flows",- %slug,- connection_id = %id,- "[flows] tool_call: POSSIBLY EXECUTING ON THE WRONG ACCOUNT — \- connection_ref names a connection id not found among the user's live \- connected accounts, and backend mode has no per-call account-scoping \- path to validate it against anyway — this call runs against the \- AMBIENT signed-in session account regardless (E-m3, documented \- backend-API-gap stub, see caps.rs's OpenHumanTools doc). Proceeds \- rather than failing closed."- ),- }- }- client- .execute_tool(slug, args_opt)- .await- .map_err(|e| EngineError::Capability(e.to_string()))- }- ComposioClientKind::Direct(tool) => {- match &resolved_account {- Some((id, Some((toolkit, _label)))) => tracing::info!(- target: "flows",- %slug,- connection_id = %id,- %toolkit,- "[flows] tool_call: executing against the resolved connected account"- ),- Some((id, None)) => tracing::warn!(- target: "flows",- %slug,- connection_id = %id,- "[flows] tool_call: connection_ref connection_id not found among the user's \- live connected accounts (stale cache or foreign id) — forwarding to \- Composio Direct mode as-is"- ),- None => tracing::debug!(- target: "flows",- %slug,- "[flows] tool_call: no connection_ref — using the ambient signed-in account"- ),- }- direct_execute(- &tool,- slug,- args_opt,- &live_config.composio.entity_id,- connection_id,- )- .await- .map_err(|e| EngineError::Capability(e.to_string()))- }- };+ match &resolved_account {+ Some((id, Some((toolkit, _label)))) => tracing::info!(+ target: "flows",+ %slug,+ connection_id = %id,+ %toolkit,+ mode = kind.mode(),+ "[flows] tool_call: executing against the resolved connected account"+ ),+ Some((id, None)) => tracing::warn!(+ target: "flows",+ %slug,+ connection_id = %id,+ mode = kind.mode(),+ "[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 = kind.mode(),+ "[flows] tool_call: no connection_ref — using the ambient signed-in account"+ ),+ }+ let response = execute_for_connection(+ kind,+ slug,+ args_opt,+ &live_config.composio.entity_id,+ connection_id,+ )+ .await;// A successful HTTP round-trip can still carry a provider-side failure// (`{successful: false, error: "..."}`, e.g. a Slack 400 on@@ -277,3 +264,65 @@ impl ToolBackend for ComposioToolBackend {serde_json::to_value(response?).map_err(|e| EngineError::Capability(e.to_string()))}}++#[cfg(test)]+mod tests {+ use std::sync::Arc;++ use axum::{routing::post, Json, Router};+ use serde_json::{json, Value};++ use super::*;+ use crate::openhuman::integrations::composio::ComposioClient;+ use crate::openhuman::integrations::IntegrationClient;++ /// Regression for #5751: the flow adapter used to parse and log the chosen+ /// account, then call `execute_tool` without it. The request therefore ran+ /// against the ambient account. Pin the final backend JSON body so that+ /// dropping the id at any point in this seam fails the test.+ #[tokio::test]+ async fn backend_dispatch_forwards_the_workflow_connection_id() {+ let app = Router::new().route(+ "/agent-integrations/composio/execute",+ post(|Json(body): Json<Value>| async move {+ assert_eq!(body["tool"], "GITHUB_LIST_REPOSITORY_ISSUES");+ assert_eq!(body["arguments"]["owner"], "tinyhumansai");+ assert_eq!(body["connectionId"], "ca_target_account");+ Json(json!({+ "success": true,+ "data": {+ "data": { "issues": [] },+ "successful": true,+ "error": null,+ "costUsd": 0.0+ }+ }))+ }),+ );+ let listener = tokio::net::TcpListener::bind("127.0.0.1:0")+ .await+ .expect("bind mock backend");+ let addr = listener.local_addr().expect("mock backend address");+ tokio::spawn(async move {+ axum::serve(listener, app)+ .await+ .expect("serve mock backend");+ });++ let client = ComposioClient::new(Arc::new(IntegrationClient::new(+ format!("http://{addr}"),+ "test-token".to_string(),+ )));+ let response = execute_for_connection(+ ComposioClientKind::Backend(client),+ "GITHUB_LIST_REPOSITORY_ISSUES",+ Some(json!({ "owner": "tinyhumansai" })),+ "unused-in-backend-mode",+ Some("ca_target_account"),+ )+ .await+ .expect("backend dispatch should succeed");++ assert!(response.successful);+ }+}diff --git a/src/openhuman/integrations/composio/client.rs b/src/openhuman/integrations/composio/client.rsindex 2a2151a61d..c0576ad064 100644--- a/src/openhuman/integrations/composio/client.rs+++ b/src/openhuman/integrations/composio/client.rs@@ -186,6 +186,22 @@ impl ComposioClient {&self,tool: &str,arguments: Option<serde_json::Value>,+ ) -> Result<ComposioExecuteResponse> {+ self.execute_tool_with_connection(tool, arguments, None)+ .await+ }++ /// `POST /agent-integrations/composio/execute` — run a Composio action+ /// against one specific connected account.+ ///+ /// `connection_id = None` preserves [`Self::execute_tool`]'s ambient-account+ /// behavior. A non-empty id is forwarded as `connectionId`; the backend+ /// verifies that the authenticated user owns it before dispatching.+ pub async fn execute_tool_with_connection(+ &self,+ tool: &str,+ arguments: Option<serde_json::Value>,+ connection_id: Option<&str>,) -> Result<ComposioExecuteResponse> {let tool = tool.trim();if tool.is_empty() {@@ -208,8 +224,16 @@ impl ComposioClient {// mode dispatch.let arguments = super::execute_prepare::prepare_execute_arguments(tool, arguments).map_err(anyhow::Error::msg)?;- tracing::debug!(tool = %tool, "[composio] execute_tool");- let body = json!({ "tool": tool, "arguments": arguments });+ let connection_id = connection_id.map(str::trim).filter(|id| !id.is_empty());+ tracing::debug!(+ tool = %tool,+ connection_id = ?connection_id,+ "[composio] execute_tool"+ );+ let mut body = json!({ "tool": tool, "arguments": arguments });+ if let Some(connection_id) = connection_id {+ body["connectionId"] = json!(connection_id);+ }let mut resp = self.execute_tool_with_post_oauth_retry(tool, &body, POST_OAUTH_ACTION_RETRY_DELAY).await?;diff --git a/src/openhuman/integrations/composio/client_tests.rs b/src/openhuman/integrations/composio/client_tests.rsindex 292a57a333..e4091f57dc 100644--- a/src/openhuman/integrations/composio/client_tests.rs+++ b/src/openhuman/integrations/composio/client_tests.rs@@ -424,6 +424,10 @@ async fn execute_tool_returns_cost_and_success_flags() {"/agent-integrations/composio/execute",post(|Json(body): Json<Value>| async move {let tool = body["tool"].as_str().unwrap_or("").to_string();+ assert!(+ body.get("connectionId").is_none(),+ "ambient execute_tool calls must omit per-account scoping"+ );Json(json!({"success": true,"data": {