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
chore: files changed crates/openhuman-core/src/memory/tools.rs
Steven Enamakel946a44728723
diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rsindex b68762ffca..359cb94a90 100644--- a/crates/openhuman-core/src/memory/tools.rs+++ b/crates/openhuman-core/src/memory/tools.rs@@ -2,12 +2,12 @@use std::future::Future;use std::pin::Pin;-use std::sync::{Arc, Mutex};+use std::sync::Arc;use std::time::Duration;use async_trait::async_trait;use serde_json::{json, Value};-use tinymemory_api::{MemoryEngine, Namespace, Reach, ThreadWindow, ToolCallRef};+use tinymemory_api::{Namespace, Reach, ThreadWindow, ToolCallRef};use tinymemory_tools::{concurrency_for, is_write_action, permission_for, CallContext, ConcurrencyClass, MemoryTools,PermissionClass, Refusal, RunBudget, SingleTool, ToolScope,@@ -138,45 +138,15 @@ impl tinymemory_tools::BudgetClock for TokioClock {pub struct MemoryTool {config: Arc<Config>,budget: RunBudget,- last_engine: Mutex<Option<Arc<dyn MemoryEngine>>>,}impl MemoryTool {/// A tool bound to `config`'s configured memory engine.#[must_use]pub fn new(config: Arc<Config>) -> Self {- let last_engine = super::engine::resolve(&config)- .engine()- .ok()- .map(|bound| bound.engine);Self {config,budget: RunBudget::new(Arc::new(TokioClock::default())),- last_engine: Mutex::new(last_engine),- }- }-- fn engine_for_call(&self) -> Result<Arc<dyn MemoryEngine>, tinymemory_api::Error> {- if super::engine::switched_off(&self.config) {- return super::engine::resolve(&self.config)- .engine()- .map(|bound| bound.engine);- }- match super::engine::resolve(&self.config).engine() {- Ok(bound) => {- let engine = bound.engine;- *self- .last_engine- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner) = Some(engine.clone());- Ok(engine)- }- Err(error) => self- .last_engine- .lock()- .unwrap_or_else(std::sync::PoisonError::into_inner)- .clone()- .ok_or(error),}}@@ -188,14 +158,23 @@ impl MemoryTool {run_id: Option<&str>,) -> ToolResult {let call = async {- let engine = match self.engine_for_call() {- Ok(engine) => engine,- Err(error) => return ToolResult::error(render_error(error)),- };- let tools = MemoryTools::with_scope(engine, facts.native_scope(&self.config));- let single = SingleTool::new(MEMORY_TOOL_NAME, tools).with_write_sink(Arc::new(- super::tool_writes::HostWriteSink::new(self.config.clone()),+ let scope = facts.native_scope(&self.config);+ let write_sink = Arc::new(super::tool_writes::HostWriteSink::new(+ self.config.clone(),));+ let single = if is_write_action(&args) {+ SingleTool::queued(MEMORY_TOOL_NAME, scope, write_sink)+ } else {+ let engine = match super::engine::resolve(&self.config).engine() {+ Ok(bound) => bound.engine,+ Err(error) => return ToolResult::error(render_error(error)),+ };+ SingleTool::new(+ MEMORY_TOOL_NAME,+ MemoryTools::with_scope(engine, scope),+ )+ .with_write_sink(write_sink)+ };let call_args = args.clone();let thread_window = facts.in_prompt.clone();let call = async move {