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
chore(composio): remove obsolete execute-tool resilience tests and unused import
Steven Enamakel0efbcad0d48d
diff --git a/crates/openhuman-core/src/integrations/composio/client.rs b/crates/openhuman-core/src/integrations/composio/client.rsindex 9b221946f5..649dca3db4 100644--- a/crates/openhuman-core/src/integrations/composio/client.rs+++ b/crates/openhuman-core/src/integrations/composio/client.rs@@ -33,6 +33,5 @@ pub use factory::{create_composio_client, ComposioClientKind};#[cfg(test)]use super::types::ComposioExecuteResponse;#[cfg(test)]-use execute::is_post_oauth_auth_readiness_error;#[cfg(test)]use std::sync::Arc;diff --git a/crates/openhuman-core/src/integrations/composio/client_authorize_and_execute_tests.rs b/crates/openhuman-core/src/integrations/composio/client_authorize_and_execute_tests.rsindex 0225727a64..bb1013287b 100644--- a/crates/openhuman-core/src/integrations/composio/client_authorize_and_execute_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/client_authorize_and_execute_tests.rs@@ -47,44 +47,6 @@ async fn authorize_rejects_empty_toolkit() {);}-/// Privacy epic S7 (#4441): under LocalOnly, both execute entry points refuse-/// the external tool call before any HTTP round-trip. The inner client points at-/// an unreachable address, so a passing test proves the gate short-circuits-/// before the network (a leaked call would fail with a transport error, not the-/// local-only message).-#[tokio::test]-async fn execute_tool_blocked_under_local_only() {- // Thread-scoped LocalOnly (see `live_policy::test_privacy_scope`) — never- // mutates the process-global policy, so it can't race sibling mock tests.- let _mode =- crate::security::live_policy::test_privacy_scope(crate::config::PrivacyMode::LocalOnly);- let inner = Arc::new(crate::integrations::IntegrationClient::new(- "http://127.0.0.1:0".into(),- "test".into(),- ));- let client = ComposioClient::new(inner);-- let err = client- .execute_tool("GITHUB_CREATE_ISSUE", None)- .await- .unwrap_err();- assert!(- err.to_string()- .contains("Local-only privacy mode is active"),- "execute_tool: unexpected error: {err}"- );- let err_once = client- .execute_tool_once("GITHUB_CREATE_ISSUE", None)- .await- .unwrap_err();- assert!(- err_once- .to_string()- .contains("Local-only privacy mode is active"),- "execute_tool_once: unexpected error: {err_once}"- );-}-/// `authorize()` must reject a non-object `extra_params` before making any HTTP call.#[tokio::test]async fn authorize_rejects_non_object_extra_params() {@@ -137,22 +99,6 @@ async fn delete_connection_rejects_empty_id() {);}-/// `execute_tool()` must refuse empty slugs — otherwise the backend-/// would receive a malformed request.-#[tokio::test]-async fn execute_tool_rejects_empty_slug() {- let inner = Arc::new(crate::integrations::IntegrationClient::new(- "http://127.0.0.1:0".into(),- "test".into(),- ));- let client = ComposioClient::new(inner);- let err = client.execute_tool("", None).await.unwrap_err();- assert!(- err.to_string().contains("tool slug must not be empty"),- "unexpected error: {err}"- );-}-/// ComposioClient is `Clone` so each tool gets a cheap handle share./// Inner client must be Arc-shared — no duplication.#[test]@@ -381,202 +327,6 @@ async fn list_tools_filters_pass_through_as_csv_query_param() {assert_eq!(resp_empty_tags.tools[0].function.name, "ECHO_gmail");}-/// Ambient execution must preserve the legacy unscoped request shape while-/// still returning provider success and cost metadata.-#[tokio::test]-async fn execute_tool_returns_cost_and_success_flags() {- let app = Router::new().route(- "/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": {- "data": { "echoed_tool": tool },- "successful": true,- "error": null,- "costUsd": 0.0025- }- }))- }),- );- let base = start_mock_backend(app).await;- let client = build_client_for(base);- let resp = client- .execute_tool("GMAIL_SEND_EMAIL", Some(json!({"to": "[email protected]"})))- .await- .unwrap();- assert!(resp.successful);- assert!((resp.cost_usd - 0.0025).abs() < f64::EPSILON);- assert_eq!(resp.data["echoed_tool"], "GMAIL_SEND_EMAIL");-}--#[tokio::test]-async fn execute_tool_retries_once_on_post_oauth_auth_readiness_error() {- let attempts = Arc::new(AtomicUsize::new(0));- let app = Router::new()- .route(- "/agent-integrations/composio/execute",- post(|State(attempts): State<Arc<AtomicUsize>>| async move {- let attempt = attempts.fetch_add(1, Ordering::SeqCst);- if attempt == 0 {- Json(json!({- "success": true,- "data": {- "data": {},- "successful": false,- "error": "Connection error, try to authenticate",- "costUsd": 0.0- }- }))- } else {- Json(json!({- "success": true,- "data": {- "data": {"ok": true},- "successful": true,- "error": null,- "costUsd": 0.001- }- }))- }- }),- )- .with_state(attempts.clone());- let base = start_mock_backend(app).await;- let client = build_client_for(base);-- let resp = client- .execute_tool_with_post_oauth_retry(- "GOOGLECALENDAR_EVENTS_LIST",- &json!({- "tool": "GOOGLECALENDAR_EVENTS_LIST",- "arguments": {}- }),- std::time::Duration::ZERO,- )- .await- .unwrap();-- assert!(resp.successful);- assert_eq!(attempts.load(Ordering::SeqCst), 2);-}--#[test]-fn post_oauth_auth_readiness_error_matches_known_gateway_variants() {- for err in [- "Connection error, try to authenticate",- "connection error, try to authenticate",- "CONNECTION ERROR, TRY TO AUTHENTICATE",- "Action failed: Connection error, try to authenticate (gateway code 401)",- ] {- assert!(- is_post_oauth_auth_readiness_error(&ComposioExecuteResponse {- data: json!({}),- successful: false,- error: Some(err.to_string()),- cost_usd: 0.0,- markdown_formatted: None,- }),- "should classify retryable Composio auth-readiness error: {err}"- );- }-}--#[test]-fn post_oauth_auth_readiness_error_rejects_unrelated_or_successful_payloads() {- for err in ["invalid_grant", "ratelimited", ""] {- assert!(- !is_post_oauth_auth_readiness_error(&ComposioExecuteResponse {- data: json!({}),- successful: false,- error: Some(err.to_string()),- cost_usd: 0.0,- markdown_formatted: None,- }),- "should not classify unrelated error as retryable: {err}"- );- }-- assert!(!is_post_oauth_auth_readiness_error(- &ComposioExecuteResponse {- data: json!({}),- successful: true,- error: Some("Connection error, try to authenticate".to_string()),- cost_usd: 0.0,- markdown_formatted: None,- }- ));-}--#[tokio::test]-async fn execute_tool_does_not_retry_other_auth_errors() {- let attempts = Arc::new(AtomicUsize::new(0));- let app = Router::new()- .route(- "/agent-integrations/composio/execute",- post(|State(attempts): State<Arc<AtomicUsize>>| async move {- attempts.fetch_add(1, Ordering::SeqCst);- Json(json!({- "success": true,- "data": {- "data": {},- "successful": false,- "error": "Invalid OAuth scope",- "costUsd": 0.0- }- }))- }),- )- .with_state(attempts.clone());- let base = start_mock_backend(app).await;- let client = build_client_for(base);-- let resp = client- .execute_tool_with_post_oauth_retry(- "GOOGLECALENDAR_EVENTS_LIST",- &json!({- "tool": "GOOGLECALENDAR_EVENTS_LIST",- "arguments": {}- }),- std::time::Duration::ZERO,- )- .await- .unwrap();-- assert!(!resp.successful);- assert_eq!(resp.error.as_deref(), Some("Invalid OAuth scope"));- assert_eq!(attempts.load(Ordering::SeqCst), 1);-}--#[tokio::test]-async fn execute_tool_without_arguments_sends_empty_object() {- let app = Router::new().route(- "/agent-integrations/composio/execute",- post(|Json(body): Json<Value>| async move {- // Verify default arguments is an object (not missing / null).- assert!(body["arguments"].is_object());- Json(json!({- "success": true,- "data": {- "data": {},- "successful": true,- "error": null,- "costUsd": 0.0- }- }))- }),- );- let base = start_mock_backend(app).await;- let client = build_client_for(base);- let resp = client.execute_tool("NOOP_ACTION", None).await.unwrap();- assert!(resp.successful);-}-#[tokio::test]async fn backend_error_envelope_becomes_bail() {let app = Router::new().route(diff --git a/crates/openhuman-core/src/integrations/composio/client_triggers_and_factory_tests.rs b/crates/openhuman-core/src/integrations/composio/client_triggers_and_factory_tests.rsindex 4601bbe403..f5efb137dc 100644--- a/crates/openhuman-core/src/integrations/composio/client_triggers_and_factory_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/client_triggers_and_factory_tests.rs@@ -166,141 +166,6 @@ async fn delete_connection_surfaces_envelope_error_detail() {// ── execute_tool resilience tests (Batch 1 — post-OAuth readiness) ─────-/// When the backend returns `{ "successful": false, "error": "..." }` inside-/// the data envelope, `execute_tool` should still succeed at the HTTP level-/// (the envelope `success: true`) but surface the failure via the `successful`-/// flag on [`ComposioExecuteResponse`]. Callers like `composio_execute` in-/// `ops.rs` inspect `resp.successful` and propagate the inner error.-///-/// This is the shape the backend sends during the post-OAuth readiness gap-/// (e.g. "App not authorized yet") — the outer `success: true` means the-/// proxy reached Composio; `successful: false` means Composio itself rejected-/// the action.-#[tokio::test]-async fn execute_tool_surfaces_non_successful_provider_response() {- let app = Router::new().route(- "/agent-integrations/composio/execute",- post(|| async {- Json(json!({- "success": true,- "data": {- "data": {},- "successful": false,- "error": "App not authorized yet — please complete OAuth first",- "costUsd": 0.0- }- }))- }),- );- let base = start_mock_backend(app).await;- let client = build_client_for(base);- // Use a slug that bypasses local arg validation in `execute_prepare`- // so the test exercises the gateway-response path, not the pre-flight.- let resp = client.execute_tool("ANY_TOOL", None).await.unwrap();- assert!(- !resp.successful,- "non-successful provider response must be surfaced via the successful flag"- );- let err = resp.error.expect("error field must be present on failure");- assert!(- err.contains("not authorized"),- "error message must pass through verbatim; got: {err}"- );- assert_eq!(resp.cost_usd, 0.0, "zero cost on failure");-}--/// A revoked-token error is a distinct failure mode from a transient-/// readiness gap — both manifest as `successful: false` but with different-/// error strings. The client must not swallow either; both must surface-/// in the `error` field so callers can classify them.-#[tokio::test]-async fn execute_tool_surfaces_revoked_token_error() {- let app = Router::new().route(- "/agent-integrations/composio/execute",- post(|| async {- Json(json!({- "success": true,- "data": {- "data": {},- "successful": false,- "error": "Token revoked: the user has disconnected their account",- "costUsd": 0.0- }- }))- }),- );- let base = start_mock_backend(app).await;- let client = build_client_for(base);- let resp = client- .execute_tool("GMAIL_FETCH_EMAILS", None)- .await- .unwrap();- assert!(!resp.successful);- let err = resp.error.unwrap();- assert!(- err.contains("revoked"),- "revoked-token message must be preserved verbatim; got: {err}"- );-}--/// A transport-level 5xx is distinct from a provider-level failure: it-/// means the backend itself failed before reaching Composio. This must-/// surface as an `Err` from `execute_tool`, not as `successful: false`,-/// so callers that only inspect the flag don't silently swallow the-/// outage.-#[tokio::test]-async fn execute_tool_propagates_backend_5xx_as_err() {- let app = Router::new().route(- "/agent-integrations/composio/execute",- post(|| async { StatusCode::INTERNAL_SERVER_ERROR }),- );- let base = start_mock_backend(app).await;- let client = build_client_for(base);- let result = client.execute_tool("ANY_TOOL", None).await;- assert!(- result.is_err(),- "5xx backend must be an Err, not Ok(unsuccessful)"- );- let msg = result.unwrap_err().to_string();- assert!(- msg.contains("500") || msg.contains("Backend returned"),- "5xx error message must contain status code; got: {msg}"- );-}--/// `execute_tool` must forward the `tool` field in the request body so-/// the backend knows which action to proxy to Composio. Regression guard-/// for any future refactor that touches the body builder.-#[tokio::test]-async fn execute_tool_sends_tool_slug_in_request_body() {- let app = Router::new().route(- "/agent-integrations/composio/execute",- post(|Json(body): Json<Value>| async move {- let tool_field = body["tool"].as_str().unwrap_or("").to_string();- Json(json!({- "success": true,- "data": {- "data": { "received_tool": tool_field },- "successful": true,- "error": null,- "costUsd": 0.0- }- }))- }),- );- let base = start_mock_backend(app).await;- let client = build_client_for(base);- let resp = client- .execute_tool("JIRA_CREATE_ISSUE", Some(json!({"project": "OH"})))- .await- .unwrap();- assert!(resp.successful);- assert_eq!(- resp.data["received_tool"], "JIRA_CREATE_ISSUE",- "tool slug must be forwarded in request body"- );-}-#[test]fn create_composio_client_backend_variant_when_mode_default() {let tmp = tempfile::tempdir().expect("tempdir");