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(memory_sources): dispatch Composio rows through the connector in Apply-all\n\nThe per-row Sync button special-cased Composio; the Apply-all sweep did not.\nIt sent every enabled row through `MemorySourceSync::run_source_sync`, which\nthe driver refuses for this kind ("... is synced through the connector module,\nnot this engine"), so "sync everything" failed for exactly the rows a user\nreaches for it to fix.\n\nTwo call sites open-coding one rule is how they drifted, so the decision is now\none pure function — `sync_dispatch` over the registry entry, returning\n`SyncDispatch::{Connector, Driver}` — and both sites match on it. The sweep's\ntrigger closure takes the whole entry rather than the id, because routing needs\nthe kind, the connection and the per-source cap.\n\nThe sweep also hard-errored as a whole when `as_source_sync()` answered `None`,\nwhich for a Composio-only profile turned Apply-all into one flat refusal over a\ncapability none of its rows use — the same finding the row-level path already\ncarries (#5932). The family is now resolved as an `Option` and refused per row,\nwhich is what this sweep already aggregates (#5820).\n\nThe reason stays `manual`: `parse_sync_reason` accepts only `manual`,\n`periodic` and `connection_created`, so a sweep-specific reason would fail\nevery Composio row with "unrecognized sync reason".\n\nThis is the secondary half of #6007. The primary half — connector items never\nreaching `mem_tree_chunks` — is fixed in tinymemory (tinyhumansai/tinymemory#134)\nand reaches users through a module release and registry re-pin, not this change.\n\nRefs #6007\n
Shanu6a580218c539
diff --git a/src/openhuman/memory/sources/rpc_part_01.rs b/src/openhuman/memory/sources/rpc_part_01.rsindex c26003b103..783df76326 100644--- a/src/openhuman/memory/sources/rpc_part_01.rs+++ b/src/openhuman/memory/sources/rpc_part_01.rs@@ -502,6 +502,53 @@ pub struct SyncResponse {pub source_id: String,}+/// Which sync path a source row belongs to.+///+/// Extracted because there are **two** callers and they disagreed. The per-row+/// Sync button ([`sync_rpc`]) special-cased Composio; the Apply-all sweep+/// ([`apply_all_in_rpc`]) dispatched every enabled row through+/// `MemorySourceSync`, which the driver refuses for Composio ("… is synced+/// through the connector module, not this engine"). So "sync everything" failed+/// for exactly the rows a user most expects it to fix (openhuman#6007). Two call+/// sites open-coding one rule is how that happened; both now match on this.+#[derive(Debug, Clone, PartialEq, Eq)]+pub(crate) enum SyncDispatch {+ /// Connector-mediated. tinymemory v1.13.4 removed the engine's in-process+ /// Composio sync, so the connector-backed run IS the sync for this kind —+ /// the same entry point the `openhuman.composio_sync` RPC uses, which reads+ /// the connected account through the module and ingests through this same+ /// binding.+ Connector {+ connection_id: String,+ max_items: Option<u32>,+ },+ /// The memory driver's own source pipeline — folder, git, RSS, and every+ /// other tree-coupled kind.+ Driver,+}++/// Resolve a source row to its sync path.+///+/// The only failure is a Composio row carrying no `connection_id`: the connector+/// call is addressed *by* connection, so there is nothing to sync and nothing to+/// guess. That is a malformed row rather than a transient fault, which is why the+/// message says to remove and re-add rather than to retry.+pub(crate) fn sync_dispatch(entry: &MemorySourceEntry) -> Result<SyncDispatch, String> {+ if entry.kind != tinymemory_sources::types::SourceKind::Composio {+ return Ok(SyncDispatch::Driver);+ }+ let connection_id = entry.connection_id.clone().ok_or_else(|| {+ format!(+ "composio source '{}' has no connection_id; remove and re-add the source",+ entry.id+ )+ })?;+ Ok(SyncDispatch::Connector {+ connection_id,+ max_items: entry.max_items,+ })+}+pub async fn sync_rpc(req: SyncRequest) -> Result<RpcOutcome<SyncResponse>, String> {tracing::info!(source_id = %req.source_id, "[memory_sources] sync_rpc: entry");@@ -522,26 +569,20 @@ pub async fn sync_rpc(req: SyncRequest) -> Result<RpcOutcome<SyncResponse>, Striif !entry.enabled {return Err(format!("source '{}' is disabled", entry.id));}- // Composio rows never reach the memory driver's pipeline: v1.13.4- // removed the engine's in-process Composio sync, and the driver now- // answers this id with "synced through the connector module, not this- // pipeline". The connector-backed run IS the sync for this kind, so- // the one Sync button dispatches there — same entry point the- // `openhuman.composio_sync` RPC uses, which reads the connected- // account through the module and ingests through this same binding.- if entry.kind == tinymemory_sources::types::SourceKind::Composio {- let connection_id = entry.connection_id.as_deref().ok_or_else(|| {- format!(- "composio source '{}' has no connection_id; remove and re-add the source",- entry.id- )- })?;+ // Composio rows never reach the memory driver's pipeline — see+ // [`SyncDispatch`], which both this button and the Apply-all sweep read+ // the rule from.+ if let SyncDispatch::Connector {+ connection_id,+ max_items,+ } = sync_dispatch(&entry)?+ {crate::openhuman::integrations::composio::ops::composio_sync_budgeted(&config,- connection_id,+ &connection_id,Some("manual".to_string()),Some(entry.id.clone()),- entry.max_items,+ max_items,).await?;return Ok(RpcOutcome::new(diff --git a/src/openhuman/memory/sources/rpc_part_02.rs b/src/openhuman/memory/sources/rpc_part_02.rsindex 45ebdb70b9..4a48b5d5b4 100644--- a/src/openhuman/memory/sources/rpc_part_02.rs+++ b/src/openhuman/memory/sources/rpc_part_02.rs@@ -415,12 +415,17 @@ pub struct AllInResponse {/// Takes the trigger as a closure rather than the driver trait object so the/// aggregation is unit-testable without a full `MemorySourceSync` stub; the/// RPC owns config/binding resolution and the response shape.+///+/// The closure receives the whole entry, not just the id: since openhuman#6007+/// the caller has to route each row by [`SyncDispatch`], which reads the kind,+/// the connection and the per-source cap. Owned rather than borrowed so the+/// returned future does not have to borrow from the sweep's loop body.async fn trigger_enabled_syncs<F, Fut>(sources: &[MemorySourceEntry],mut trigger: F,) -> (u32, Vec<String>)where- F: FnMut(String) -> Fut,+ F: FnMut(MemorySourceEntry) -> Fut,Fut: std::future::Future<Output = Result<(), String>>,{let mut sync_triggered: u32 = 0;@@ -434,7 +439,7 @@ wherekind = %source.kind.as_str(),"[memory_sources] apply_all_in_rpc: triggering sync");- match trigger(source.id.clone()).await {+ match trigger(source.clone()).await {Ok(()) => {sync_triggered += 1;}@@ -469,22 +474,51 @@ pub async fn apply_all_in_rpc() -> Result<RpcOutcome<AllInResponse>, String> {// Trigger a background sync for every enabled source.let config = config_rpc::load_config_with_timeout().await?;- // Resolved once for the whole sweep: a driver that serves no sync has- // nothing to say about any source, and refusing per source would turn one- // fact into a warning per row.let binding = crate::openhuman::memory::binding::for_config(&config)?;- let sync = binding.provider().as_source_sync().ok_or_else(|| {- format!(- "the bound memory driver '{}' does not serve source sync",- binding.driver_id()- )- })?;-- let (sync_triggered, sync_errors) = trigger_enabled_syncs(&sources, |source_id| async move {- sync.run_source_sync(&source_id)+ // Resolved once for the whole sweep, but as an `Option` rather than a hard+ // error. A driver that serves `as_sources` without `as_source_sync` can+ // still sync every Composio row through the connector, and failing the whole+ // sweep over a capability those rows never use is the review finding the+ // row-level path already carries (#5932) — for a Composio-only user it+ // turned "sync everything" into one flat refusal. A row that genuinely needs+ // the family reports the refusal as its own per-source error, which is+ // exactly what this sweep aggregates.+ let source_sync = binding.provider().as_source_sync();+ let config_ref = &config;+ let driver_id = binding.driver_id();++ let (sync_triggered, sync_errors) = trigger_enabled_syncs(&sources, move |source| async move {+ match sync_dispatch(&source)? {+ // The connector-backed run IS the sync for this kind, so the sweep+ // takes the same dispatch the per-row Sync button does. Before+ // openhuman#6007 every Composio row came back "synced through the+ // connector module, not this engine" here.+ SyncDispatch::Connector {+ connection_id,+ max_items,+ } => crate::openhuman::integrations::composio::ops::composio_sync_budgeted(+ config_ref,+ &connection_id,+ // `manual`, not a sweep-specific reason: Apply-all is a user+ // action, and `parse_sync_reason` accepts only `manual`,+ // `periodic` and `connection_created` — an invented reason would+ // fail every Composio row here with "unrecognized sync reason".+ Some("manual".to_string()),+ Some(source.id.clone()),+ max_items,+ ).await- .map(|_| ())- .map_err(|error| error.to_string())+ .map(|_| ()),+ SyncDispatch::Driver => {+ let sync = source_sync.ok_or_else(|| {+ format!("the bound memory driver '{driver_id}' does not serve source sync")+ })?;+ sync.run_source_sync(&source.id)+ .await+ .map(|_| ())+ .map_err(|error| error.to_string())+ }+ }}).await;diff --git a/src/openhuman/memory/sources/rpc_tests.rs b/src/openhuman/memory/sources/rpc_tests.rsindex 54a709f515..04f71bacca 100644--- a/src/openhuman/memory/sources/rpc_tests.rs+++ b/src/openhuman/memory/sources/rpc_tests.rs@@ -74,12 +74,13 @@ async fn trigger_sweep_aggregates_failures_instead_of_laundering_them() {// Succeeds for ids starting `ok`, refuses everything else the way the// incident did.- let (triggered, errors) = trigger_enabled_syncs(&sources, |source_id| async move {- if source_id.starts_with("ok") {+ let (triggered, errors) = trigger_enabled_syncs(&sources, |source| async move {+ if source.id.starts_with("ok") {Ok(())} else {Err(format!(- "not found: no memory source registered as {source_id}"+ "not found: no memory source registered as {}",+ source.id))}})@@ -99,3 +100,66 @@ async fn trigger_sweep_aggregates_failures_instead_of_laundering_them() {errors[1]);}++/// openhuman#6007: the per-row Sync button and the Apply-all sweep must route a+/// row the same way, so the decision is one function and this is its test.+///+/// The bug was not that either call site was wrong in isolation — it was that+/// there were two of them. Apply-all sent Composio rows through+/// `MemorySourceSync`, which the driver refuses for exactly that kind, so "sync+/// everything" failed for every connector source. Asserting the *rule* is what+/// stops the two drifting again; a test that drove a full sync could not, since+/// these handlers read the bound driver and are not reachable from a test.+#[test]+fn composio_rows_dispatch_to_the_connector_and_everything_else_to_the_driver() {+ fn composio(id: &str, connection_id: Option<&str>) -> MemorySourceEntry {+ let mut entry: MemorySourceEntry = serde_json::from_value(serde_json::json!({+ "id": id,+ "kind": "composio",+ "label": "Gmail",+ "enabled": true,+ "toolkit": "gmail",+ "connection_id": connection_id,+ }))+ .expect("a valid composio source entry");+ // Set through the struct rather than the JSON so this test does not+ // depend on `max_items` being an accepted input field for the kind.+ entry.max_items = Some(25);+ entry+ }++ fn folder(id: &str) -> MemorySourceEntry {+ serde_json::from_value(serde_json::json!({+ "id": id,+ "kind": "folder",+ "label": "Notes",+ "enabled": true,+ "path": ".",+ }))+ .expect("a valid folder source entry")+ }++ assert_eq!(+ sync_dispatch(&composio("src_gmail", Some("ca_1"))).expect("a connected composio row"),+ SyncDispatch::Connector {+ connection_id: "ca_1".to_string(),+ max_items: Some(25),+ },+ "a Composio row must route to the connector, carrying its connection and cap"+ );++ assert_eq!(+ sync_dispatch(&folder("src_notes")).expect("a folder row"),+ SyncDispatch::Driver,+ "every non-Composio kind stays on the driver's own pipeline"+ );++ // A connection-less Composio row is malformed, not retryable: the connector+ // call is addressed by connection, so there is nothing to sync.+ let error = sync_dispatch(&composio("src_broken", None))+ .expect_err("a composio row with no connection cannot be dispatched");+ assert!(+ error.contains("src_broken") && error.contains("remove and re-add"),+ "the refusal must name the row and say what to do about it, got: {error}"+ );+}