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
feat(memory): confine recall, store, forget, and list to the user's tree
Steven Enamakel3ff7da4bb7b3
diff --git a/crates/openhuman-core/src/memory/mod.rs b/crates/openhuman-core/src/memory/mod.rsindex e3674d68df..6b05070174 100644--- a/crates/openhuman-core/src/memory/mod.rs+++ b/crates/openhuman-core/src/memory/mod.rs@@ -36,6 +36,7 @@ pub mod sources;pub mod status;pub mod tools;pub mod types;+pub mod user_scope;#[cfg(test)]pub(crate) mod test_fixtures;diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex dc0fa88649..239acd7b00 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -147,7 +147,7 @@ pub async fn recall(config: &Config, params: RecallParams) -> MemoryResult<Recallet bound = bound(config)?;let request = RecallRequest {question: params.question,- filter: params.filter.unwrap_or_default(),+ filter: confine_filter(config, params.filter.unwrap_or_default()),limit: clamp_limit(params.limit),instructions: None,};@@ -271,7 +271,10 @@ pub async fn learn(}/// Scrubs `item` and stores it on the bound engine.-pub async fn store_item(config: &Config, item: StoreItem) -> MemoryResult<StoreReceipt> {+pub async fn store_item(config: &Config, mut item: StoreItem) -> MemoryResult<StoreReceipt> {+ if let Some(root) = super::user_scope::confinement(config) {+ super::user_scope::clamp_item(&mut item, &root);+ }let bound = bound(config)?;store_on(&bound, item).await}@@ -320,7 +323,12 @@ pub async fn forget(config: &Config, params: ForgetParams) -> MemoryResult<Forgereturn Err(MemoryError::invalid("forget needs at least one id"));}let bound = bound(config)?;- let ids = match params.reach {+ // A SaaS user forgets only what lies in their own tree.+ let reach = match super::user_scope::confinement(config) {+ Some(root) => Some(super::user_scope::clamp_reach(params.reach, &root)),+ None => params.reach,+ };+ let ids = match reach {Some(reach) => within_reach(&bound, ids, reach).await?,None => ids,};@@ -360,7 +368,7 @@ async fn within_reach(pub async fn items_list(config: &Config, params: ItemsListParams) -> MemoryResult<ItemsListView> {let bound = bound(config)?;let request = ListRequest {- filter: super::explore::narrowed(params.filter, ¶ms.path)?,+ filter: confine_filter(config, super::explore::narrowed(params.filter, ¶ms.path)?),limit: clamp_limit(params.limit),cursor: params.cursor,};@@ -372,6 +380,15 @@ pub async fn items_list(config: &Config, params: ItemsListParams) -> MemoryResul})}+/// `filter`, confined to the SaaS user's tree when `config` has one+/// ([`super::user_scope`]).+pub(crate) fn confine_filter(config: &Config, filter: MetaFilter) -> MetaFilter {+ match super::user_scope::confinement(config) {+ Some(root) => super::user_scope::clamp_filter(filter, &root),+ None => filter,+ }+}+#[cfg(test)]#[path = "ops_tests.rs"]mod tests;