Skip to content

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

fix(composio): publish sync stage events so the Sources row can settle\n\nThe Brain sources row clears its "Syncing" indicator only when a terminal\nMemorySyncStageChanged event arrives (#3295). The driver pipeline's events\ncome from the module host bridge; the composio path never crossed it, so a\nsuccessful connector sync left the row spinning forever -- observed live\nagainst prod after every deadline fix landed: background sync ok,\nitems written, spinner immortal.\n\nThe background task now publishes running/completed/failed stages on the\nsame bus variant the bridge uses, with the toolkit as provider, the\nconnection id, an item-count detail, and -- when the sync was dispatched\nfrom a memory-source row -- the originating source_id, which\ncomposio_sync_for_source threads through from sync_rpc's kind branch.\n

Shanu9f635f57be28
diff --git a/src/openhuman/integrations/composio/ops/mod.rs b/src/openhuman/integrations/composio/ops/mod.rs
index 66a393e9a3..59f81c0d63 100644
--- a/src/openhuman/integrations/composio/ops/mod.rs
+++ b/src/openhuman/integrations/composio/ops/mod.rs
@@ -42,7 +42,7 @@ pub(crate) use error_utils::{report_composio_op_error, should_forward_tags};
pub use execute::composio_execute;
pub use providers_ops::{
composio_get_user_profile, composio_refresh_all_identities, composio_sync,
- RefreshIdentitiesReport,
+ composio_sync_for_source, RefreshIdentitiesReport,
};
// The tinyconnectors-mediated sync pass, shared with
// `memory::sync::composio::providers::slack::rpc` — see its doc comment.
diff --git a/src/openhuman/integrations/composio/ops/providers_ops.rs b/src/openhuman/integrations/composio/ops/providers_ops.rs
index 908ee15b92..d52d03710f 100644
--- a/src/openhuman/integrations/composio/ops/providers_ops.rs
+++ b/src/openhuman/integrations/composio/ops/providers_ops.rs
@@ -186,6 +186,21 @@ pub async fn composio_sync(
config: &Config,
connection_id: &str,
reason: Option<String>,
+) -> OpResult<RpcOutcome<SyncOutcome>> {
+ composio_sync_for_source(config, connection_id, reason, None).await
+}
+
+/// [`composio_sync`], carrying the originating memory-source row id so the
+/// background task can publish `MemorySyncStageChanged` events the Brain
+/// sources row keys its per-row indicator on (#3295). The composio path never
+/// emitted them — the driver pipeline's events come from the module host
+/// bridge, which this path does not cross — so a successful sync left the row
+/// on "Syncing" forever, waiting for a terminal stage that never arrived.
+pub async fn composio_sync_for_source(
+ config: &Config,
+ connection_id: &str,
+ reason: Option<String>,
+ source_id: Option<String>,
) -> OpResult<RpcOutcome<SyncOutcome>> {
let reason = parse_sync_reason(reason.as_deref())?;
tracing::debug!(
@@ -213,37 +228,68 @@ pub async fn composio_sync(
)
.unwrap_or(u64::MAX);
- let config_for_task = config.clone();
let toolkit_for_task = toolkit.clone();
let connection_for_task = connection_id.to_string();
let reason_for_task = reason.as_str().to_string();
+ let source_for_task = source_id.clone();
+
+ let publish_stage = move |stage: &str, detail: Option<String>| {
+ crate::core::bus::BUS.publish(crate::core::events::DomainEvent::MemorySyncStageChanged {
+ trigger: "manual".to_string(),
+ stage: stage.to_string(),
+ provider: Some(toolkit_for_task.clone()),
+ connection_id: Some(connection_for_task.clone()),
+ detail,
+ source_id: source_for_task.clone(),
+ });
+ };
+
+ let toolkit_for_log = toolkit.clone();
+ let connection_for_log = connection_id.to_string();
+ let config_for_run = config.clone();
tokio::spawn(async move {
+ publish_stage("running", None);
let outcome = run_sync_pass(
- &config_for_task,
- &toolkit_for_task,
- &connection_for_task,
+ &config_for_run,
+ &toolkit_for_log,
+ &connection_for_log,
&reason_for_task,
)
.await;
match outcome {
- Ok(pass) => tracing::info!(
- toolkit = %toolkit_for_task,
- connection_id = %connection_for_task,
- items_ingested = pass.records_read,
- written = pass.written,
- already_ingested = pass.already_ingested,
- more_pending = pass.more_pending,
- "[composio] background sync ok"
- ),
+ Ok(pass) => {
+ tracing::info!(
+ toolkit = %toolkit_for_log,
+ connection_id = %connection_for_log,
+ items_ingested = pass.records_read,
+ written = pass.written,
+ already_ingested = pass.already_ingested,
+ more_pending = pass.more_pending,
+ "[composio] background sync ok"
+ );
+ publish_stage(
+ "completed",
+ Some(format!(
+ "{} items{}",
+ pass.written,
+ if pass.more_pending {
+ ", more pending"
+ } else {
+ ""
+ }
+ )),
+ );
+ }
Err(error) => {
report_composio_op_error("sync", &anyhow::anyhow!("{error}"));
tracing::warn!(
- toolkit = %toolkit_for_task,
- connection_id = %connection_for_task,
+ toolkit = %toolkit_for_log,
+ connection_id = %connection_for_log,
error = %error,
"[composio] background sync failed"
);
+ publish_stage("failed", Some(error.clone()));
}
}
});
diff --git a/src/openhuman/memory/sources/rpc_part_01.rs b/src/openhuman/memory/sources/rpc_part_01.rs
index bf6ff25ef2..0332270c57 100644
--- a/src/openhuman/memory/sources/rpc_part_01.rs
+++ b/src/openhuman/memory/sources/rpc_part_01.rs
@@ -542,10 +542,11 @@ pub async fn sync_rpc(req: SyncRequest) -> Result<RpcOutcome<SyncResponse>, Stri
entry.id
)
})?;
- crate::openhuman::integrations::composio::ops::composio_sync(
+ crate::openhuman::integrations::composio::ops::composio_sync_for_source(
&config,
connection_id,
Some("manual".to_string()),
+ Some(entry.id.clone()),
)
.await?;
return Ok(RpcOutcome::new(