Skip to content

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

refactor(memory): use retrieval provider for recall

Steven Enamakel95b31b0cd5a8
diff --git a/src/openhuman/memory/read_rpc/chunks.rs b/src/openhuman/memory/read_rpc/chunks.rs
index cc28585a06..5e92a9dc61 100644
--- a/src/openhuman/memory/read_rpc/chunks.rs
+++ b/src/openhuman/memory/read_rpc/chunks.rs
@@ -3,7 +3,9 @@ use std::collections::{HashMap, HashSet};
use crate::openhuman::config::Config;
use crate::openhuman::memory::api::provider::{ChunkListRow, ChunkQuery};
-use crate::openhuman::memory::tree::retrieval::types::NodeKind;
+use crate::openhuman::memory::api::provider::retrieval::{
+ RetrievalNodeKind, RetrievalResponse, SourceRetrievalQuery,
+};
use crate::rpc::RpcOutcome;
use tinymemory_api::chunks::SourceKind;
@@ -405,26 +407,39 @@ pub async fn recall_rpc(
// and recall would run unrestricted regardless of the active profile's
// `memory_sources` allowlist. Mirrors `query_source_rpc` in
// `tree/retrieval/rpc.rs`.
- let resp = crate::openhuman::memory::tree::retrieval::source::query_source_scoped(
- config,
- crate::openhuman::memory::tree::retrieval::source::SourceQuery {
- source_id: None,
- source_kind: None,
- time_window_days: None,
- query: Some(query.as_str()),
- limit,
- },
- crate::openhuman::memory::source_scope::current_source_scope(),
- )
- .await
- .map_err(|e| format!("recall query_source: {e:#}"))?;
+ let scope = crate::openhuman::memory::source_scope::as_bus_scope();
+ let binding = crate::openhuman::memory::binding::for_config(config)?;
+ let resp = match binding.provider().as_retrieval() {
+ Some(retrieval) => retrieval
+ .retrieve_source(
+ &SourceRetrievalQuery {
+ source_id: None,
+ source_kind: None,
+ time_window_days: None,
+ query: Some(query.clone()),
+ limit,
+ },
+ scope.as_ref(),
+ )
+ .await
+ .map_err(|e| format!("recall query_source: {e}"))?,
+ // Read-only, so an empty page is the honest answer: a driver with no
+ // retrieval family keeps no summary tree to rank.
+ None => {
+ log::debug!(
+ "[memory_tree::read::recall] driver '{}' does not serve Retrieval; reporting empty",
+ binding.driver_id()
+ );
+ RetrievalResponse::default()
+ }
+ };
let mut chunk_rows: Vec<ChunkRow> = Vec::new();
let mut scores: Vec<f32> = Vec::new();
let leaves: Vec<(String, f32)> = resp
.hits
.into_iter()
- .filter(|h| matches!(h.node_kind, NodeKind::Summary) && h.level == 1)
+ .filter(|h| matches!(h.node_kind, RetrievalNodeKind::Summary) && h.level == 1)
.flat_map(|h| {
h.child_ids
.into_iter()