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): add tool write tracking to memory engine
Steven Enamakel10b794858922
diff --git a/crates/openhuman-core/src/memory/engine.rs b/crates/openhuman-core/src/memory/engine.rsindex caeea42489..a1dadf6f8c 100644--- a/crates/openhuman-core/src/memory/engine.rs+++ b/crates/openhuman-core/src/memory/engine.rs@@ -205,6 +205,10 @@ fn host_engine() -> Option<BoundEngine> {/// Resolves the configured engine.#[must_use]pub fn resolve(config: &Config) -> Binding {+ if !config.components.memory {+ tracing::debug!("[memory:engine] components.memory is off; engine not bound");+ return off(None, None, COMPONENT_OFF_REASON);+ }if let Some(capabilities) = crate::profiles::capabilities::ProfileCapabilities::current() {if let Some(engine) = &capabilities.memory_engine {if let Err(reason) = crate::profiles::host::ensure_hosted() {@@ -277,6 +281,9 @@ pub fn resolve(config: &Config) -> Binding {/// installed engine is bound, which has one layout of its own and cannot be/// bound below a scope root.pub fn bind_with_root(config: &Config, root: Option<&str>) -> MemoryResult<BoundEngine> {+ if !config.components.memory {+ return Err(MemoryError::Off(COMPONENT_OFF_REASON.to_string()));+ }#[cfg(test)]{let installed = TEST_ROOT_ENGINES@@ -368,6 +375,16 @@ fn resolve_configured(config: &Config, root: Option<&str>) -> Binding {}}+/// Why memory answers off while `[components] memory = false`.+const COMPONENT_OFF_REASON: &str = "memory component is disabled ([components] memory = false)";++/// Whether memory is switched off by config: `[components] memory = false` or+/// `[memory] engine = "none"`. No engine is bound in either case.+#[must_use]+pub fn switched_off(config: &Config) -> bool {+ !config.components.memory || config.memory.engine == DISABLED_ENGINE+}+/// Whether memory is on for `config`.#[must_use]pub fn is_on(config: &Config) -> bool {diff --git a/crates/openhuman-core/src/memory/engine_tests.rs b/crates/openhuman-core/src/memory/engine_tests.rsindex d8dfd2f0b2..e4de716b10 100644--- a/crates/openhuman-core/src/memory/engine_tests.rs+++ b/crates/openhuman-core/src/memory/engine_tests.rs@@ -412,3 +412,26 @@ fn host_binding_refuses_a_scope_root_outside_saas() {None);}++#[test]+fn a_disabled_memory_component_binds_no_engine() {+ let tmp = tempfile::tempdir().unwrap();+ let mut config = config_in(&tmp);+ config.components.memory = false;+ assert!(off_reason(resolve(&config)).contains("components"));+ assert!(!is_on(&config));+ assert!(switched_off(&config));+ assert!(matches!(+ bind_with_root(&config, None),+ Err(MemoryError::Off(_))+ ));+}++#[test]+fn a_disabled_component_overrides_an_installed_test_engine() {+ let tmp = tempfile::tempdir().unwrap();+ let mut config = config_in(&tmp);+ assert!(!switched_off(&config));+ config.memory.engine = DISABLED_ENGINE.to_string();+ assert!(switched_off(&config));+}diff --git a/crates/openhuman-core/src/memory/tool_writes.rs b/crates/openhuman-core/src/memory/tool_writes.rsindex fd6cff155c..99a8662c24 100644--- a/crates/openhuman-core/src/memory/tool_writes.rs+++ b/crates/openhuman-core/src/memory/tool_writes.rs@@ -161,7 +161,7 @@ pub(super) fn enqueue(args: &serde_json::Value,facts: &CallFacts,) -> MemoryResult<serde_json::Value> {- if config.memory.engine == super::engine::DISABLED_ENGINE {+ if super::engine::switched_off(config) {return Err(MemoryError::Off("memory is disabled".into()));}let confinement = super::user_scope::confinement(config)?;@@ -459,7 +459,7 @@ pub(super) fn schedule(config: Arc<Config>) {/// Retries all durable partitions belonging to this owner on auth/cron ticks.pub(super) fn schedule_all(config: Arc<Config>) {- if config.memory.engine == super::engine::DISABLED_ENGINE {+ if super::engine::switched_off(config) {return;}crate::core::runtime::spawn_scoped(async move {@@ -565,7 +565,7 @@ impl WriteExecutor for Executor<'_> {}async fn drain_locked(config: &Config, file: &Path, state: &OwnerState, generation: u64) -> usize {- if config.memory.engine == super::engine::DISABLED_ENGINE {+ if super::engine::switched_off(config) {return 0;}let active = binding(config);