Skip to content

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

fix(flows): apply static Composio arg rules in the tool_call preflight

M3gA-Mind61a03d8a693f
diff --git a/src/openhuman/flows/tinyflows/caps/ops.rs b/src/openhuman/flows/tinyflows/caps/ops.rs
index 70d9b9f3a5..67df4ba7b8 100644
--- a/src/openhuman/flows/tinyflows/caps/ops.rs
+++ b/src/openhuman/flows/tinyflows/caps/ops.rs
@@ -407,15 +407,41 @@ pub struct OpenHumanTools {
/// with a message that names the field and the likely fix — instead of letting
/// the raw provider error surface from deep inside the call.
///
-/// Best-effort by design: when the action's schema cannot be looked up the
-/// check is skipped (never blocks on catalog availability).
+/// Two independent halves:
+///
+/// 1. The **static** rules `prepare_execute_arguments` already enforces at
+/// dispatch (`GMAIL_SEND_EMAIL` needs a recipient, `GOOGLECALENDAR_*` time
+/// bounds must be RFC 3339, …). These need no catalog, no network and no
+/// API key, so they always run.
+/// 2. The **catalog-driven** required-arg list, which is best-effort: when the
+/// action's schema cannot be looked up that half is skipped (never blocks
+/// on catalog availability).
+///
+/// Before #6154 only (2) existed, so a host with no reachable Composio
+/// catalog — the common case in a dry run, and any offline/unkeyed run — had
+/// a preflight that silently passed everything and left the failure to
+/// surface from inside the dispatch instead.
pub(crate) async fn preflight_composio_args(
config: &Config,
slug: &str,
args: &Value,
) -> Result<()> {
+ // (1) Static rules — the same validation the Composio dispatch runs, hoisted
+ // ahead of it. Only the `Err` matters here; the normalized arguments it
+ // returns are recomputed (and used) at dispatch.
+ if let Err(e) =
+ crate::openhuman::integrations::composio::execute_prepare::prepare_execute_arguments(
+ slug,
+ Some(args.clone()),
+ )
+ {
+ tracing::warn!(target: "flows", %slug, error = %e, "[flows] preflight: static arg rule rejected the call — failing before dispatch");
+ return Err(EngineError::Capability(format!("tool_call `{slug}`: {e}")));
+ }
+
+ // (2) Catalog-driven required args.
let Some(required) = composio_required_args(config, slug).await else {
- tracing::debug!(target: "flows", %slug, "[flows] preflight: no schema for action — skipping required-arg check");
+ tracing::info!(target: "flows", %slug, "[flows] preflight: no live catalog schema for action — required-arg check limited to static rules");
return Ok(());
};
let missing = missing_required_args(&required, args);
diff --git a/src/openhuman/flows/tinyflows/tinyflows_tests_part_01_tests.rs b/src/openhuman/flows/tinyflows/tinyflows_tests_part_01_tests.rs
index 01898f1bb3..d684b44b4d 100644
--- a/src/openhuman/flows/tinyflows/tinyflows_tests_part_01_tests.rs
+++ b/src/openhuman/flows/tinyflows/tinyflows_tests_part_01_tests.rs
@@ -378,6 +378,41 @@ async fn preflight_skips_when_no_schema_is_available() {
.expect("preflight must be best-effort when no schema is available");
}
+#[tokio::test]
+async fn preflight_applies_static_arg_rules_without_a_catalog() {
+ let tmp = TempDir::new().unwrap();
+ let config = test_config(&tmp);
+ // No catalog seeding for this slug — `GMAIL_ADD_LABEL_TO_EMAIL` is never
+ // seeded anywhere, so `composio_required_args` returns `None` whether or
+ // not another test has cached the `gmail` toolkit. That used to make the
+ // whole preflight inert (#6154): the node sailed through and only failed
+ // at dispatch, inside `prepare_execute_arguments`.
+ //
+ // Those dispatch-time rules are static — no catalog, no network, no key —
+ // so the preflight must apply them regardless of catalog availability.
+ let err = super::super::caps::preflight_composio_args(
+ &config,
+ "GMAIL_ADD_LABEL_TO_EMAIL",
+ &json!({ "add_label_ids": ["INBOX"] }),
+ )
+ .await
+ .expect_err("a statically-known missing required arg must fail preflight");
+ let msg = err.to_string();
+ assert!(
+ msg.contains("message_id"),
+ "error must name the missing field: {msg}"
+ );
+
+ // Args that satisfy the static rules still pass (no catalog needed).
+ super::super::caps::preflight_composio_args(
+ &config,
+ "GMAIL_ADD_LABEL_TO_EMAIL",
+ &json!({ "message_id": "abc123", "add_label_ids": ["INBOX"] }),
+ )
+ .await
+ .expect("statically-valid args must pass preflight");
+}
+
#[tokio::test]
async fn preflight_invoker_gates_the_mock_tool_path() {
use tinyflows::caps::ToolInvoker as _;