Skip to content

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

fix: only normalize prefixed Composio errors\n\n

Steven Enamakel24826e8069ce
diff --git a/src/openhuman/integrations/composio/module_client.rs b/src/openhuman/integrations/composio/module_client.rs
index e941d0c1e4..7f349272a7 100644
--- a/src/openhuman/integrations/composio/module_client.rs
+++ b/src/openhuman/integrations/composio/module_client.rs
@@ -41,13 +41,17 @@ pub fn is_unsupported_by_route(error: &str) -> bool {
/// TinyBus prefixes member failures (for example, `Execute: `), but the
/// frontend parser intentionally requires the classification at byte zero.
/// Other errors retain the member context unchanged.
-fn normalize_error(error: String) -> String {
+fn normalize_error(member: &str, error: String) -> String {
const CLASSIFIED: &str = "[composio:error:";
- if let Some(start) = error.find(CLASSIFIED) {
- error[start..].to_string()
- } else {
- error
+ if let Some(module_error) = error
+ .strip_prefix(member)
+ .and_then(|remainder| remainder.strip_prefix(": "))
+ {
+ if module_error.starts_with(CLASSIFIED) {
+ return module_error.to_string();
+ }
}
+ error
}
/// The message a gates-off build answers every connector call with.
@@ -78,7 +82,7 @@ where
{
crate::openhuman::modules::connectors::call(config, member, request)
.await
- .map_err(normalize_error)
+ .map_err(|error| normalize_error(member, error))
}
/// Call one member with an argument. Always fails without the `modules` feature.
@@ -111,7 +115,7 @@ pub async fn call_bare<Reply: serde::de::DeserializeOwned>(
) -> Result<Reply, String> {
crate::openhuman::modules::connectors::call_bare(config, member)
.await
- .map_err(normalize_error)
+ .map_err(|error| normalize_error(member, error))
}
/// Call a member that takes no arguments. Always fails without `modules`.
diff --git a/src/openhuman/integrations/composio/module_client_tests.rs b/src/openhuman/integrations/composio/module_client_tests.rs
index 183a0e5241..7ecd5b8e20 100644
--- a/src/openhuman/integrations/composio/module_client_tests.rs
+++ b/src/openhuman/integrations/composio/module_client_tests.rs
@@ -6,6 +6,7 @@ use super::{is_unsupported_by_route, methods};
fn classified_errors_start_with_the_frontend_marker() {
assert_eq!(
super::normalize_error(
+ methods::EXECUTE,
"Execute: [composio:error:rate_limited] Please retry later".to_string()
),
"[composio:error:rate_limited] Please retry later"
@@ -15,11 +16,21 @@ fn classified_errors_start_with_the_frontend_marker() {
#[test]
fn unclassified_errors_keep_the_member_context() {
assert_eq!(
- super::normalize_error("Execute: module unavailable".to_string()),
+ super::normalize_error(methods::EXECUTE, "Execute: module unavailable".to_string()),
"Execute: module unavailable"
);
}
+#[test]
+fn embedded_classification_text_is_not_promoted() {
+ let error =
+ "Execute: provider returned [composio:error:rate_limited] as plain text".to_string();
+ assert_eq!(
+ super::normalize_error(methods::EXECUTE, error.clone()),
+ error
+ );
+}
+
#[test]
fn member_names_come_from_the_contract() {
// Spelled through `tinyconnectors_bus` rather than as string literals, so a