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(connectors): handle composio network errors without panicking
Steven Enamakel610723c9fd76
diff --git a/crates/openhuman-core/src/integrations/composio/client.rs b/crates/openhuman-core/src/integrations/composio/client.rsindex dd89cc236f..b6ce83955f 100644--- a/crates/openhuman-core/src/integrations/composio/client.rs+++ b/crates/openhuman-core/src/integrations/composio/client.rs@@ -25,7 +25,7 @@ pub use direct::direct_list_connections;pub(crate) use direct::direct_list_tools;pub(crate) use factory::create_direct_client_for_api_key;pub use factory::{resolve_composio_route, ComposioRoute};-pub(crate) use network::module_transport;+pub(crate) use network::{module_transport, module_transport_with_proxy};// Brought into this module's own namespace (private `use`, not `pub use`)// so `client_tests.rs` — declared as a direct child module of `client`diff --git a/crates/openhuman-core/src/integrations/composio/client/network.rs b/crates/openhuman-core/src/integrations/composio/client/network.rsindex 0323f49823..a712a3982f 100644--- a/crates/openhuman-core/src/integrations/composio/client/network.rs+++ b/crates/openhuman-core/src/integrations/composio/client/network.rs@@ -38,7 +38,16 @@ fn usable(url: Option<&String>) -> Option<String> {/// The network policy for a request to `base_url`, or `None` when it is the/// module's default (no proxy of the host's choosing, bundled roots).pub(crate) fn module_transport(base_url: &str) -> Option<ComposioTransportConfig> {- let proxy = runtime_proxy_config();+ module_transport_with_proxy(base_url, &runtime_proxy_config())+}++/// [`module_transport`] against an explicit proxy policy instead of the+/// process-global runtime one, so a caller (or a test) that already holds the+/// policy does not race every config load that republishes the global.+pub(crate) fn module_transport_with_proxy(+ base_url: &str,+ proxy: &crate::config::schema::ProxyConfig,+) -> Option<ComposioTransportConfig> {let proxy_url = if proxy.should_apply_to_service(SERVICE_KEY) {let https = base_url.trim().to_ascii_lowercase().starts_with("https://");usable(proxy.all_proxy.as_ref()).or_else(|| {diff --git a/crates/openhuman-core/src/modules/connectors.rs b/crates/openhuman-core/src/modules/connectors.rsindex 25250ed943..45215bcfbb 100644--- a/crates/openhuman-core/src/modules/connectors.rs+++ b/crates/openhuman-core/src/modules/connectors.rs@@ -64,6 +64,15 @@ pub use names::methods;/// loudly rather than silently downgrading to the other route, which would send/// a user's requests somewhere they did not choose.pub fn module_config(config: &Config) -> Result<serde_json::Value, String> {+ module_config_with_proxy(config, &crate::config::runtime_proxy_config())+}++/// [`module_config`] against an explicit proxy policy rather than the+/// process-global runtime one.+pub(crate) fn module_config_with_proxy(+ config: &Config,+ proxy: &crate::config::schema::ProxyConfig,+) -> Result<serde_json::Value, String> {let state_dir = config.workspace_dir.join("state");// A host-pinned credential outranks the mode and the credential store, the@@ -82,7 +91,7 @@ pub fn module_config(config: &Config) -> Result<serde_json::Value, String> {"state_dir": state_dir,});if let Some(transport) =- crate::integrations::composio::client::module_transport(destination)+ crate::integrations::composio::client::module_transport_with_proxy(destination, proxy){payload["transport"] = serde_json::json!(transport);}@@ -165,7 +174,7 @@ pub fn module_config(config: &Config) -> Result<serde_json::Value, String> {.as_deref().unwrap_or("https://backend.composio.dev/api/v3");if let Some(transport) =- crate::integrations::composio::client::module_transport(destination)+ crate::integrations::composio::client::module_transport_with_proxy(destination, proxy){payload["transport"] = serde_json::json!(transport);}diff --git a/crates/openhuman-core/src/modules/connectors_tests.rs b/crates/openhuman-core/src/modules/connectors_tests.rsindex ff151a8582..8af48e5f4a 100644--- a/crates/openhuman-core/src/modules/connectors_tests.rs+++ b/crates/openhuman-core/src/modules/connectors_tests.rs@@ -89,27 +89,28 @@ fn direct_mode_takes_the_api_key_from_the_config_file() {fn direct_mode_hands_the_module_the_hosts_proxy_policy() {// Part of the route description, so a proxy change reconfigures the module.use crate::config::schema::{ProxyConfig, ProxyScope};- use crate::config::{runtime_proxy_config, set_runtime_proxy_config};- let _env = crate::config::TEST_ENV_LOCK.blocking_lock();let mut config = bare_config();config.composio.mode = COMPOSIO_MODE_DIRECT.to_string();config.composio.api_key = Some("sk-from-file".to_string());- let previous = runtime_proxy_config();- set_runtime_proxy_config(ProxyConfig {- enabled: true,- https_proxy: Some("http://127.0.0.1:3128".into()),- no_proxy: vec!["localhost".into()],- // Scoped to Composio so no other test's loopback request is proxied.- scope: ProxyScope::Services,- services: vec!["tool.composio".into()],- ..ProxyConfig::default()- });- let proxied = module_config(&config).expect("resolves");- set_runtime_proxy_config(ProxyConfig::default());- let plain = module_config(&config).expect("resolves");- set_runtime_proxy_config(previous);+ // The policy is passed in rather than installed as the process-global+ // runtime proxy: every config load republishes that global, so installing+ // it here raced any concurrent test that loads a config.+ let proxied = module_config_with_proxy(+ &config,+ &ProxyConfig {+ enabled: true,+ https_proxy: Some("http://127.0.0.1:3128".into()),+ no_proxy: vec!["localhost".into()],+ // Scoped to Composio so no other test's loopback request is proxied.+ scope: ProxyScope::Services,+ services: vec!["tool.composio".into()],+ ..ProxyConfig::default()+ },+ )+ .expect("resolves");+ let plain = module_config_with_proxy(&config, &ProxyConfig::default()).expect("resolves");assert_eq!(proxied["transport"]["proxy_url"], "http://127.0.0.1:3128");assert_eq!(proxied["transport"]["no_proxy"][0], "localhost");