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): forget by id within reach instead of sweeping the tree
Steven Enamakel375bab31122b
diff --git a/crates/openhuman-core/src/channels/bus/subscriber.rs b/crates/openhuman-core/src/channels/bus/subscriber.rsindex 1fafdf6f0d..307e15bf19 100644--- a/crates/openhuman-core/src/channels/bus/subscriber.rs+++ b/crates/openhuman-core/src/channels/bus/subscriber.rs@@ -67,7 +67,9 @@ impl EventHandler<DomainEvent> for ChannelInboundSubscriber {// If that contract is broken, the legacy channel-only key would let// different users share one chat session and its prepared wallet quote.if channel.split(':').next() == Some("discord")- && sender.as_deref().is_none_or(|value| value.trim().is_empty())+ && sender+ .as_deref()+ .is_none_or(|value| value.trim().is_empty()){tracing::warn!("[channel-inbound] dropping Discord message without sender id");return;diff --git a/crates/openhuman-core/src/memory/guard.rs b/crates/openhuman-core/src/memory/guard.rsindex e8f74f9cb3..40da0e01d8 100644--- a/crates/openhuman-core/src/memory/guard.rs+++ b/crates/openhuman-core/src/memory/guard.rs@@ -20,8 +20,8 @@ use async_trait::async_trait;use tinymemory_api::{BeliefsRequest, ConsolidateReceipt, ConsolidateRequest, EngineDescriptor, EngineHealth,EraseReport, EraseRequest, ExplorePage, ExploreRequest, ExportPage, FetchPage, FetchRequest,- ForgetReport, ForgetTarget, GetRequest, Hit, ListPage, ListRequest, MemoryEngine, RecallAnswer,- RecallRequest, Result, StoreItem, StoreReceipt, WaitFor, WriteOptions,+ ForgetReport, ForgetTarget, GetRequest, Hit, ItemId, ListPage, ListRequest, MemoryEngine,+ Reach, RecallAnswer, RecallRequest, Result, StoreItem, StoreReceipt, WaitFor, WriteOptions,};use super::error::MemoryError;@@ -166,6 +166,18 @@ impl MemoryEngine for ScrubbingEngine {.await}+ // Forwarded, not left to the default: the default reads back through+ // this wrapper's `get` and then calls `forget(ForgetTarget::Ids)`, which+ // on the inner engine sweeps the whole tree for the ids.+ async fn forget_within(&self, ids: Vec<ItemId>, reach: Reach) -> Result<ForgetReport> {+ self.timed(+ "forget_within",+ self.inner.forget_within(ids, reach),+ |report| report.forgotten,+ )+ .await+ }+async fn list(&self, req: ListRequest) -> Result<ListPage> {self.timed("list", self.inner.list(req), |page| page.items.len()).awaitdiff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex 17032584ba..3f028355c9 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -386,15 +386,20 @@ pub async fn forget(config: &Config, params: ForgetParams) -> MemoryResult<ForgeSome(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,+ let report = match reach {+ // With a reach the engine forgets by id inside it: `forget_within`+ // never looks beyond the reach for an id, where `ForgetTarget::Ids`+ // sweeps every scope of the tree to find one.+ Some(reach) => {+ let ids = within_reach(&bound, ids, reach.clone()).await?;+ if ids.is_empty() {+ tracing::debug!(engine = %bound.id, "[memory:ops] forget: nothing in reach");+ return Ok(ForgetView { forgotten: 0 });+ }+ bound.engine.forget_within(ids, reach).await?+ }+ None => bound.engine.forget(ForgetTarget::Ids(ids)).await?,};- if ids.is_empty() {- tracing::debug!(engine = %bound.id, "[memory:ops] forget: nothing in reach");- return Ok(ForgetView { forgotten: 0 });- }- let report = bound.engine.forget(ForgetTarget::Ids(ids)).await?;tracing::debug!(engine = %bound.id, forgotten = report.forgotten, "[memory:ops] forget");Ok(ForgetView {forgotten: report.forgotten,diff --git a/crates/openhuman-core/src/memory/test_fixtures.rs b/crates/openhuman-core/src/memory/test_fixtures.rsindex 6282c644b5..6f3ccbdc4e 100644--- a/crates/openhuman-core/src/memory/test_fixtures.rs+++ b/crates/openhuman-core/src/memory/test_fixtures.rs@@ -211,6 +211,15 @@ impl MemoryEngine for RecordingEngine {self.inner.forget(target).await}+ async fn forget_within(+ &self,+ ids: Vec<tinymemory_api::ItemId>,+ reach: tinymemory_api::Reach,+ ) -> tinymemory_api::Result<tinymemory_api::ForgetReport> {+ self.calls.lock().unwrap().push("forget_within");+ self.inner.forget_within(ids, reach).await+ }+async fn list(&self, req: ListRequest) -> tinymemory_api::Result<tinymemory_api::ListPage> {self.inner.list(req).await}