Skip to content

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

test(composio): move preflight arg tests next to the gate they cover

Steven Enamakel0ac626ccc511
diff --git a/crates/openhuman-core/src/flows/tinyflows/tinyflows_capabilities_tests.rs b/crates/openhuman-core/src/flows/tinyflows/tinyflows_capabilities_tests.rs
index a1c840328b..760d6e8c6a 100644
--- a/crates/openhuman-core/src/flows/tinyflows/tinyflows_capabilities_tests.rs
+++ b/crates/openhuman-core/src/flows/tinyflows/tinyflows_capabilities_tests.rs
@@ -275,103 +275,6 @@ fn http_cred_name_returns_none_for_non_http_cred_ref_or_empty_name() {
// ── structured agent output (parse_llm_json) ────────────────────────────
-// ── tool_call required-arg preflight ─────────────────────────────────────
-
-#[tokio::test]
-async fn preflight_fails_before_dispatch_naming_the_missing_field() {
- let tmp = TempDir::new().unwrap();
- let config = test_config(&tmp);
- // Seed the schema cache so no live Composio backend is needed. Uses its
- // own toolkit/slug (never `"gmail"`) — the process-global
- // `LIVE_CATALOG_CACHE` is shared with every `#[tokio::test]` in this
- // file, and `preflight_invoker_gates_the_mock_tool_path` below seeds a
- // DIFFERENT required-args list under the same slug; under parallel
- // execution one test could overwrite the other's cache entry between
- // seed and assert, making both flaky.
- crate::integrations::composio::catalog::seed_live_catalog_cache(
- "preflightfailtest",
- vec![seeded_required_args_contract(
- "PREFLIGHTFAILTEST_SEND_EMAIL",
- "preflightfailtest",
- &["to", "subject", "body"],
- )],
- );
-
- // `to` resolved to null (the classic mis-wired agent → tool_call case).
- let err = super::super::caps::preflight_composio_args(
- &config,
- "PREFLIGHTFAILTEST_SEND_EMAIL",
- &json!({ "to": null, "subject": "hi", "body": "text" }),
- )
- .await
- .expect_err("null required arg must fail preflight");
- let msg = err.to_string();
- assert!(msg.contains("`to`"), "error must name the field: {msg}");
- assert!(
- msg.contains("=nodes.<node_id>.item.json.<field>"),
- "error must suggest the wiring fix: {msg}"
- );
- assert!(
- msg.contains("output schema"),
- "error must mention the agent output schema rule: {msg}"
- );
-
- // Fully-wired args pass.
- super::super::caps::preflight_composio_args(
- &config,
- "PREFLIGHTFAILTEST_SEND_EMAIL",
- &json!({ "to": "[email protected]", "subject": "hi", "body": "text" }),
- )
- .await
- .expect("wired args must pass preflight");
-}
-
-#[tokio::test]
-async fn preflight_skips_when_no_schema_is_available() {
- let tmp = TempDir::new().unwrap();
- let config = test_config(&tmp);
- // A slug whose toolkit is unknown to the curation catalog has no schema
- // source at all — the preflight must skip, never block.
- super::super::caps::preflight_composio_args(&config, "NOT_A_REAL_TOOLKIT_ACTION", &json!({}))
- .await
- .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 _;
diff --git a/crates/openhuman-core/src/integrations/composio/flow_gate_tests.rs b/crates/openhuman-core/src/integrations/composio/flow_gate_tests.rs
index 37a1016200..ca0fe379f0 100644
--- a/crates/openhuman-core/src/integrations/composio/flow_gate_tests.rs
+++ b/crates/openhuman-core/src/integrations/composio/flow_gate_tests.rs
@@ -314,3 +314,93 @@ fn classify_composio_action_for_tier_matches_curated_scope_fail_safe() {
);
}
+
+fn seeded_required_args_contract(slug: &str, toolkit: &str, required: &[&str]) -> ToolContract {
+ ToolContract {
+ slug: slug.to_string(),
+ toolkit: toolkit.to_string(),
+ description: None,
+ required_args: required.iter().map(|name| name.to_string()).collect(),
+ input_schema: Some(serde_json::json!({
+ "type": "object",
+ "required": required,
+ })),
+ output_fields: Vec::new(),
+ output_schema: None,
+ primary_array_path: None,
+ is_curated: false,
+ }
+}
+
+#[tokio::test]
+async fn preflight_fails_before_dispatch_naming_the_missing_field() {
+ let config = Config::default();
+ seed_live_catalog_cache(
+ "preflightfailtest",
+ vec![seeded_required_args_contract(
+ "PREFLIGHTFAILTEST_SEND_EMAIL",
+ "preflightfailtest",
+ &["to", "subject", "body"],
+ )],
+ );
+
+ let message = preflight_composio_args(
+ &config,
+ "PREFLIGHTFAILTEST_SEND_EMAIL",
+ &serde_json::json!({ "to": null, "subject": "hi", "body": "text" }),
+ )
+ .await
+ .expect_err("null required arg must fail preflight");
+ assert!(message.contains("`to`"), "error must name the field: {message}");
+ assert!(
+ message.contains("=nodes.<node_id>.item.json.<field>"),
+ "error must suggest the wiring fix: {message}"
+ );
+ assert!(
+ message.contains("output schema"),
+ "error must mention the agent output schema rule: {message}"
+ );
+
+ preflight_composio_args(
+ &config,
+ "PREFLIGHTFAILTEST_SEND_EMAIL",
+ &serde_json::json!({ "to": "[email protected]", "subject": "hi", "body": "text" }),
+ )
+ .await
+ .expect("wired args must pass preflight");
+}
+
+#[tokio::test]
+async fn preflight_skips_when_no_schema_is_available() {
+ preflight_composio_args(
+ &Config::default(),
+ "NOT_A_REAL_TOOLKIT_ACTION",
+ &serde_json::json!({}),
+ )
+ .await
+ .expect("preflight must be best-effort when no schema is available");
+}
+
+#[tokio::test]
+async fn preflight_applies_static_arg_rules_without_a_catalog() {
+ let config = Config::default();
+ let message = preflight_composio_args(
+ &config,
+ "GMAIL_ADD_LABEL_TO_EMAIL",
+ &serde_json::json!({ "add_label_ids": ["INBOX"] }),
+ )
+ .await
+ .expect_err("a statically-known missing required arg must fail preflight");
+ assert!(
+ message.contains("message_id"),
+ "error must name the missing field: {message}"
+ );
+
+ preflight_composio_args(
+ &config,
+ "GMAIL_ADD_LABEL_TO_EMAIL",
+ &serde_json::json!({ "message_id": "abc123", "add_label_ids": ["INBOX"] }),
+ )
+ .await
+ .expect("statically-valid args must pass preflight");
+}