From 2b31337bb1dcca5b199acd3bfdadbdc70cb23c71 Mon Sep 17 00:00:00 2001 From: Steven Enamakel <31011319+senamakel@users.noreply.github.com> Date: Sun, 3 May 2026 23:17:38 -0700 Subject: [PATCH] fix(composio): per-action tool consumes backend markdownFormatted (#1167) --- src/openhuman/composio/action_tool.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/openhuman/composio/action_tool.rs b/src/openhuman/composio/action_tool.rs index 7413b2fac..b22eb8246 100644 --- a/src/openhuman/composio/action_tool.rs +++ b/src/openhuman/composio/action_tool.rs @@ -134,9 +134,27 @@ impl Tool for ComposioActionTool { elapsed_ms, }, ); - Ok(ToolResult::success( - serde_json::to_string(&resp).unwrap_or_else(|_| "{}".into()), - )) + // Mirror `ComposioExecuteTool::execute` (composio/tools.rs): + // prefer the backend-rendered `markdownFormatted` for LLM + // consumption when present, fall back to the raw JSON + // envelope on absence or non-success. Keeps both routes + // (dispatcher + per-action) consistent so the model sees + // the same compact transcript regardless of which tool + // surface integrations_agent picked. + let body = if resp.successful { + match resp + .markdown_formatted + .as_deref() + .map(str::trim) + .filter(|s| !s.is_empty()) + { + Some(md) => md.to_string(), + None => serde_json::to_string(&resp).unwrap_or_else(|_| "{}".into()), + } + } else { + serde_json::to_string(&resp).unwrap_or_else(|_| "{}".into()) + }; + Ok(ToolResult::success(body)) } Err(e) => { crate::core::event_bus::publish_global(