Skip to content

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

fix(composio): persist trigger history and dedupe repeated events

Steven Enamakel783e28dfcf59
diff --git a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
index fad9e9b667..c2c79a4da4 100644
--- a/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
+++ b/crates/openhuman-core/src/integrations/composio/bus/trigger_subscriber.rs
@@ -110,7 +110,7 @@ impl EventHandler<DomainEvent> for ComposioTriggerSubscriber {
..Default::default()
},
};
- if let Err(error) = store.record(&config, event).await {
+ if let Err(error) = store.record(&ctx, &config, event).await {
tracing::warn!(error = %error, "[composio][history] failed to archive trigger");
}
}
diff --git a/crates/openhuman-core/src/integrations/composio/ops/triggers.rs b/crates/openhuman-core/src/integrations/composio/ops/triggers.rs
index cbb5dd4ccf..1f814fd2f1 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/triggers.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/triggers.rs
@@ -210,6 +210,7 @@ pub async fn composio_disable_trigger(
}
pub async fn composio_list_trigger_history(
+ ctx: &crate::core::runtime::DispatchCtx,
config: &Config,
limit: Option<usize>,
) -> OpResult<Outcome<ComposioTriggerHistoryResult>> {
@@ -229,7 +230,7 @@ pub async fn composio_list_trigger_history(
"[composio] list_trigger_history failed: trigger archive owner unavailable".to_owned()
})?;
let history = store
- .read(config, Some(requested_limit))
+ .read(ctx, config, Some(requested_limit))
.await
.map_err(|error| format!("[composio] list_trigger_history failed: {error}"))?;
let count = history.entries.len();
diff --git a/crates/openhuman-core/src/integrations/composio/trigger_history.rs b/crates/openhuman-core/src/integrations/composio/trigger_history.rs
index 32bcef8cde..e2563b63d0 100644
--- a/crates/openhuman-core/src/integrations/composio/trigger_history.rs
+++ b/crates/openhuman-core/src/integrations/composio/trigger_history.rs
@@ -80,6 +80,7 @@ impl TriggerHistory {
async fn acquire(
&self,
+ ctx: &DispatchCtx,
config: &Config,
) -> Result<tokio::sync::OwnedMutexGuard<Option<Lease>>, String> {
let lease = Arc::clone(&self.lease);
@@ -87,7 +88,7 @@ impl TriggerHistory {
let client = self.client(&config);
// Keep ownership installation running if the caller is cancelled while
// OpenArchive completes. A later close can still release the handle.
- crate::core::runtime::DispatchCtx::ambient().spawn(async move {
+ ctx.spawn(async move {
let mut guard = lease.lock_owned().await;
Self::ensure_lease(&config, &mut guard, client).await?;
Ok(guard)
@@ -115,10 +116,11 @@ impl TriggerHistory {
/// Archive one delivered event, serialized with reads and scope changes.
pub async fn record(
&self,
+ ctx: &DispatchCtx,
config: &Config,
event: ComposioTriggerEvent,
) -> Result<ComposioTriggerHistoryEntry, String> {
- let lease = self.acquire(config).await?;
+ let lease = self.acquire(ctx, config).await?;
let handle = lease.as_ref().expect("lease installed").handle.clone();
lease
.as_ref()
@@ -136,10 +138,11 @@ impl TriggerHistory {
/// Read persisted history without changing the user's connector route.
pub async fn read(
&self,
+ ctx: &DispatchCtx,
config: &Config,
limit: Option<usize>,
) -> Result<ComposioTriggerHistoryResult, String> {
- let lease = self.acquire(config).await?;
+ let lease = self.acquire(ctx, config).await?;
let handle = lease.as_ref().expect("lease installed").handle.clone();
lease
.as_ref()