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(composio): hold reasons to 300 chars; fail a pass that fills the cap
Shanu07926627ec67
diff --git a/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rs b/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rsindex a20e9d3040..92d701d2d6 100644--- a/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/pass_failure.rs@@ -79,12 +79,17 @@ fn one_line(message: &str) -> String {message.split_whitespace().collect::<Vec<_>>().join(" ")}-/// `message` cut to [`MAX_REASON_CHARS`] characters, on a character boundary.+/// `message` cut to at most [`MAX_REASON_CHARS`] characters, the ellipsis that+/// marks the cut included, on a character boundary.fn clip(message: String) -> String {- match message.char_indices().nth(MAX_REASON_CHARS) {- Some((cut, _)) => format!("{}…", message[..cut].trim_end()),- None => message,+ if message.chars().count() <= MAX_REASON_CHARS {+ return message;}+ let cut = message+ .char_indices()+ .nth(MAX_REASON_CHARS - 1)+ .map_or(message.len(), |(index, _)| index);+ format!("{}…", message[..cut].trim_end())}/// How long to wait before asking again after `failed_attempts` consecutive@@ -101,6 +106,19 @@ pub(crate) fn retry_delay(failed_attempts: u32) -> Option<Duration> {Some(Duration::from_secs(5 * 2_u64.pow(failed_attempts - 1)))}+/// [`retry_delay`], unless the failed pass left no room under the run's item+/// cap.+///+/// A failed pass still writes what it read, and that can fill the cap. Waiting+/// then only reaches the loop's cap check, which ends the run as completed and+/// loses the failure; ending it here reports the failure with what was written.+pub(crate) fn retry_after_failure(failed_attempts: u32, cap_left: bool) -> Option<Duration> {+ if !cap_left {+ return None;+ }+ retry_delay(failed_attempts)+}+#[cfg(test)]#[path = "pass_failure_tests.rs"]mod tests;diff --git a/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rs b/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rsindex 427a186f5c..a7eddc6a48 100644--- a/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/pass_failure_tests.rs@@ -77,11 +77,18 @@ fn a_long_reason_is_cut_to_the_limit() {let reason = failure_reason(SyncStage::Failed, Some(&long), "notion").expect("a failure");assert_eq!(reason.chars().count(),- MAX_REASON_CHARS + 1,- "the limit plus the ellipsis"+ MAX_REASON_CHARS,+ "the ellipsis counts toward the limit");assert!(reason.ends_with('…'));+ let one_over = "z".repeat(MAX_REASON_CHARS + 1);+ assert_eq!(+ failure_reason(SyncStage::Failed, Some(&one_over), "notion").map(|r| r.chars().count()),+ Some(MAX_REASON_CHARS),+ "one character over is cut, not kept"+ );+let exact = "y".repeat(MAX_REASON_CHARS);assert_eq!(failure_reason(SyncStage::Failed, Some(&exact), "notion"),@@ -95,10 +102,21 @@ fn a_reason_is_cut_on_a_character_boundary() {// Multi-byte characters: a byte-offset cut would panic or split one.let long = "é".repeat(MAX_REASON_CHARS + 10);let reason = failure_reason(SyncStage::Failed, Some(&long), "slack").expect("a failure");- assert_eq!(reason.chars().count(), MAX_REASON_CHARS + 1);+ assert_eq!(reason.chars().count(), MAX_REASON_CHARS);assert!(reason.starts_with('é') && reason.ends_with('…'));}+#[test]+fn a_failed_pass_that_filled_the_item_cap_is_not_retried() {+ assert_eq!(retry_after_failure(1, true), Some(Duration::from_secs(5)));+ assert_eq!(+ retry_after_failure(1, false),+ None,+ "no room left: the run ends failed rather than completing at the cap"+ );+ assert_eq!(retry_after_failure(MAX_FAILED_ATTEMPTS, true), None);+}+#[test]fn the_retry_schedule_waits_five_then_ten_seconds_then_gives_up() {assert_eq!(retry_delay(0), None, "nothing has failed yet");diff --git a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rsindex 507a0dcce9..4c9e55037a 100644--- a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs+++ b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs@@ -23,7 +23,7 @@ use super::super::types::{use super::connections::resolve_toolkit_for_connection;use super::connector_runs::{self, ConnectorRun};use super::error_utils::{report_composio_op_error, OpResult};-use super::pass_failure::{pass_failure, retry_delay};+use super::pass_failure::{pass_failure, retry_after_failure};use super::source_rows::source_sync_depth_days;use crate::memory::api::provider::types::SourceItem;use crate::memory::api::types::MemoryTaint;@@ -349,9 +349,12 @@ pub async fn composio_sync_budgeted(total_written = total_written.saturating_add(u64::from(pass.written));// A failed pass keeps what it read (counted above); the run// waits, then asks again a bounded number of times (openhuman#6255).+ // Not when that pass filled the item cap: the cap check would+ // end the run next and report the failure as a success.if let Some(reason) = pass.failure {failed_attempts += 1;- let Some(delay) = retry_delay(failed_attempts) else {+ let cap_left = next_pass_budget(source_max_items, total_written).is_some();+ let Some(delay) = retry_after_failure(failed_attempts, cap_left) else {break Err(reason);};tracing::info!(