Skip to content

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

fix(memory): resolve the sources sink before a connector pages

Shanu172d5a49477b
diff --git a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs
index 89e100a1e7..561a35918b 100644
--- a/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs
+++ b/crates/openhuman-core/src/integrations/composio/ops/providers_ops.rs
@@ -554,6 +554,20 @@ pub(crate) async fn run_sync_pass(
// through the years. `None` reads unbounded, as every earlier release did.
let depth_days = source_sync_depth_days(config, toolkit, connection_id);
+ // The sink first, the fetch second. A connector run saves the
+ // connection's cursor as it pages (`tinyconnectors-sync`'s pipeline), so
+ // records fetched for a driver that cannot accept them are never fetched
+ // again: resolving the sink after the call lost every pass's records for
+ // good — on a remote engine without the Sources family, every connection,
+ // every periodic tick.
+ let binding = crate::memory::binding::for_config(config)?;
+ let sink = binding.provider().as_sources().ok_or_else(|| {
+ format!(
+ "the bound memory driver '{}' does not accept source items",
+ binding.driver_id()
+ )
+ })?;
+
let response = connectors::call_slow::<_, ConnectorSyncResponse>(
config,
methods::SYNC,
@@ -591,14 +605,6 @@ pub(crate) async fn run_sync_pass(
});
}
- let binding = crate::memory::binding::for_config(config)?;
- let sink = binding.provider().as_sources().ok_or_else(|| {
- format!(
- "the bound memory driver '{}' does not accept source items",
- binding.driver_id()
- )
- })?;
-
// `ConnectorRecord` and memory's `SourceItem` carry the same seven keys —
// the contract crate asserts that against a literal list, so a drift is a
// failing test there rather than a decode error here.
diff --git a/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rs b/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rs
index e81d6c13ef..0981bbf71a 100644
--- a/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rs
+++ b/crates/openhuman-core/src/memory/sources/rpc/cost_reporting.rs
@@ -49,17 +49,22 @@ pub async fn sync_audit_log_rpc() -> Result<Outcome<SyncAuditLogResponse>, Strin
tracing::debug!("[memory_sources] sync_audit_log_rpc: entry");
let config = config_rpc::load_config_with_timeout().await?;
let binding = crate::memory::binding::for_config(&config)?;
- let Some(sync) = binding.provider().as_source_sync() else {
- return Err(unserved(&binding, "source sync", "sync_audit_log"));
- };
// `None` = the driver's own cap. A caller cannot raise it by asking for
// more, so passing a number here would only be this host inventing a
// ceiling the driver then clamps anyway.
- let driver_entries = sync
- .sync_audit_log(None)
- .await
- .map_err(|error| format!("sync audit log: {error}"))?;
+ //
+ // A driver that schedules no syncs of its own keeps no audit log, and the
+ // host's log is then the whole history — every run this host drove.
+ // Refusing would hide those runs behind the driver's absence, which is
+ // what a remote engine showed: an error where Sync History should be.
+ let driver_entries = match binding.provider().as_source_sync() {
+ Some(sync) => sync
+ .sync_audit_log(None)
+ .await
+ .map_err(|error| format!("sync audit log: {error}"))?,
+ None => Vec::new(),
+ };
let host_entries = run_history::read_runs(&config.workspace_dir, run_history::KEEP_ROWS)
.map_err(|error| format!("sync run log: {error}"))?;
let (driver_rows, host_rows) = (driver_entries.len(), host_entries.len());