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): prevent duplicate memory entries on agent startup
Steven Enamakel2b1d3bd7ace1
diff --git a/crates/openhuman-core/src/agent/learning/startup.rs b/crates/openhuman-core/src/agent/learning/startup.rsindex c644c4f9bb..2f226cd035 100644--- a/crates/openhuman-core/src/agent/learning/startup.rs+++ b/crates/openhuman-core/src/agent/learning/startup.rs@@ -77,8 +77,7 @@ pub fn register_learning_subscribers(workspace_dir: std::path::PathBuf) {/// configured off, which is the one state in which a rebuild loop has nothing/// to rebuild against.fn memory_is_bindable(workspace_dir: &Path) -> bool {- use crate::config::schema::MemorySubsystemConfig;- match crate::memory::binding::for_workspace(workspace_dir, &MemorySubsystemConfig::default()) {+ match bound_memory(workspace_dir) {Ok(binding) if binding.disables_memory() => {tracing::warn!(driver = %binding.driver_id(),@@ -100,6 +99,27 @@ fn memory_is_bindable(workspace_dir: &Path) -> bool {}}+/// The memory binding for `workspace_dir`, honouring the selected engine.+///+/// The ambient context carries the workspace's `[subsystems.memory]` config+/// (including a memory-engine switch), so learning binds to the engine the user+/// chose rather than always to the default module. Without a context for this+/// workspace (a bare unit-test boot) it falls back to the default config.+///+/// Note the facet cache built from this is created once at boot; a later+/// engine switch does not re-point it until the next start.+fn bound_memory(+ workspace_dir: &Path,+) -> Result<std::sync::Arc<crate::memory::binding::MemoryBinding>, String> {+ use crate::config::schema::MemorySubsystemConfig;+ if let Some(ctx) = crate::core::runtime::context::CoreContext::current() {+ if ctx.workspace_dir().ok().as_deref() == Some(workspace_dir) {+ return ctx.memory_binding();+ }+ }+ crate::memory::binding::for_workspace(workspace_dir, &MemorySubsystemConfig::default())+}+fn register_email_signature_once<F>(handle_cell: &OnceLock<Option<SubscriptionHandle>>, register: F)whereF: FnOnce() -> Option<SubscriptionHandle>,@@ -130,8 +150,7 @@ wherefn facet_cache_for(workspace_dir: &std::path::Path,) -> Option<crate::agent::learning::cache::FacetCache> {- use crate::config::schema::MemorySubsystemConfig;- match crate::memory::binding::for_workspace(workspace_dir, &MemorySubsystemConfig::default()) {+ match bound_memory(workspace_dir) {Ok(binding) => Some(crate::agent::learning::cache::FacetCache::new(binding.guard(),)),diff --git a/crates/openhuman-core/src/memory/ops/guard.rs b/crates/openhuman-core/src/memory/ops/guard.rsindex 19f6de5f2e..cfae7ae7b0 100644--- a/crates/openhuman-core/src/memory/ops/guard.rs+++ b/crates/openhuman-core/src/memory/ops/guard.rs@@ -101,12 +101,12 @@ pub(crate) async fn active_memory_guard() -> Result<Arc<MemoryGuard>, String> {}}- let workspace_dir = fallback_workspace_dir().await?;+ let (workspace_dir, memory_subsystem) = fallback_binding_inputs().await?;log::debug!("[memory:guard] no context binding; guarding workspace={}",workspace_dir.display());- Ok(binding::for_workspace(&workspace_dir, &MemorySubsystemConfig::default())?.guard())+ Ok(binding::for_workspace(&workspace_dir, &memory_subsystem)?.guard())}#[cfg(test)]