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): let the model date a recall or fetch with refers_to
M3gA-Mind4695ee1c074e
diff --git a/crates/openhuman-core/src/flows/memory_tools.rs b/crates/openhuman-core/src/flows/memory_tools.rsindex a0d85d9b96..4112b1f911 100644--- a/crates/openhuman-core/src/flows/memory_tools.rs+++ b/crates/openhuman-core/src/flows/memory_tools.rs@@ -352,6 +352,7 @@ impl Tool for FlowMemoryRecallTool {match crate::memory::ops::recall(&config,RecallParams {+ refers_to: None,question: query.to_string(),filter: Some(filter),limit: Some(limit),diff --git a/crates/openhuman-core/src/flows/tinyflows/memory_adapter.rs b/crates/openhuman-core/src/flows/tinyflows/memory_adapter.rsindex 65f0e3b362..6eabe81ffa 100644--- a/crates/openhuman-core/src/flows/tinyflows/memory_adapter.rs+++ b/crates/openhuman-core/src/flows/tinyflows/memory_adapter.rs@@ -250,6 +250,7 @@ impl MemoryProvider for OpenHumanMemory {let page = crate::memory::ops::fetch(&self.config,FetchParams {+ refers_to: None,query: query.to_string(),mode: None,filter,@@ -270,6 +271,7 @@ impl MemoryProvider for OpenHumanMemory {let view = crate::memory::ops::recall(&self.config,RecallParams {+ refers_to: None,question: query.to_string(),filter,limit: Some(limit),diff --git a/crates/openhuman-core/src/memory/ops.rs b/crates/openhuman-core/src/memory/ops.rsindex 4dd350f21d..a33c8639a7 100644--- a/crates/openhuman-core/src/memory/ops.rs+++ b/crates/openhuman-core/src/memory/ops.rs@@ -9,7 +9,7 @@use chrono::Utc;use tinymemory_api::{FetchRequest, ForgetTarget, ItemId, LearningKind, ListRequest, MemoryMeta, RecallRequest,- StoreItem, StoreReceipt, WriteOptions,+ StoreItem, StoreReceipt, TimeHint, WriteOptions,};use crate::config::Config;@@ -19,7 +19,7 @@ use super::error::{MemoryError, MemoryResult};use super::types::{clamp_limit, EngineSetParams, EngineStatus, EngineView, EnginesListView, FetchParams,FetchView, ForgetParams, ForgetView, ItemsListParams, ItemsListView, LearnParams, LearnView,- RecallParams, RecallView,+ RecallParams, RecallView, RefersTo,};/// Default confidence of a learning stored without one.@@ -142,6 +142,17 @@ fn bound(config: &Config) -> MemoryResult<BoundEngine> {engine::resolve(config).engine()}+/// The [`TimeHint`] for `refers_to`, in the user's time zone+/// ([`Config::time_zone`]).+fn time_hint(config: &Config, refers_to: Option<RefersTo>) -> MemoryResult<Option<TimeHint>> {+ let Some(RefersTo { from, to }) = refers_to else {+ return Ok(None);+ };+ TimeHint::new(from, to.unwrap_or(from), Some(config.time_zone()))+ .map(Some)+ .map_err(MemoryError::from)+}+/// `memory_recall`.pub async fn recall(config: &Config, params: RecallParams) -> MemoryResult<RecallView> {let bound = bound(config)?;@@ -150,7 +161,7 @@ pub async fn recall(config: &Config, params: RecallParams) -> MemoryResult<Recalfilter: params.filter.unwrap_or_default(),limit: clamp_limit(params.limit),instructions: None,- refers_to: None,+ refers_to: time_hint(config, params.refers_to)?,};request.validate()?;let answer = bound.engine.recall(request).await?;@@ -188,7 +199,7 @@ pub async fn fetch(config: &Config, params: FetchParams) -> MemoryResult<FetchVilimit: clamp_limit(params.limit),cursor: params.cursor,beliefs: 0,- refers_to: None,+ refers_to: time_hint(config, params.refers_to)?,};request.validate()?;let page = bound.engine.fetch(request).await?;diff --git a/crates/openhuman-core/src/memory/ops_tests.rs b/crates/openhuman-core/src/memory/ops_tests.rsindex d370c09f4c..201f3ae53d 100644--- a/crates/openhuman-core/src/memory/ops_tests.rs+++ b/crates/openhuman-core/src/memory/ops_tests.rs@@ -21,6 +21,7 @@ async fn every_engine_operation_reports_memory_off_without_an_engine() {let recall_error = recall(&config,RecallParams {+ refers_to: None,question: "anything?".into(),filter: None,limit: None,@@ -33,6 +34,7 @@ async fn every_engine_operation_reports_memory_off_without_an_engine() {let fetch_error = fetch(&config,FetchParams {+ refers_to: None,query: "x".into(),mode: None,filter: None,@@ -94,6 +96,7 @@ async fn learn_recall_fetch_list_and_forget_round_trip() {let answer = recall(&config,RecallParams {+ refers_to: None,question: "coffee".into(),filter: None,limit: Some(5),@@ -106,6 +109,7 @@ async fn learn_recall_fetch_list_and_forget_round_trip() {let page = fetch(&config,FetchParams {+ refers_to: None,query: "coffee".into(),mode: None,filter: Some(MetaFilter {@@ -335,6 +339,7 @@ async fn fetch_refuses_a_mode_the_engine_does_not_declare() {let error = fetch(&config,FetchParams {+ refers_to: None,query: "x".into(),mode: Some(FetchMode::Keyword),filter: None,diff --git a/crates/openhuman-core/src/memory/tools.rs b/crates/openhuman-core/src/memory/tools.rsindex 2c87d67d1b..f562019bd3 100644--- a/crates/openhuman-core/src/memory/tools.rs+++ b/crates/openhuman-core/src/memory/tools.rs@@ -305,7 +305,8 @@ impl Tool for MemoryTool {`learn` stores a durable fact, preference, procedure or correction about the \user or their work, shared with every agent working alongside you; `forget` \removes items by id. Relevant memory is already added to each turn as \- <memory-context>; use `recall` or `fetch` to look further. Recall before asking \+ <memory-context>; use `recall` or `fetch` to look further, and set `refers_to` when \+ the question is about a particular time. Recall before asking \the user something they may already have told you; learn things worth \remembering next time."}@@ -325,6 +326,16 @@ impl Tool for MemoryTool {"filter": {"type": "object", "description": "recall/fetch: metadata filter, e.g. {\"kinds\": [\"learning\"], \"workspace\": \"/path\", \"repo\": \"owner/name\"}."},"limit": {"type": "integer", "minimum": 1, "maximum": 100, "description": "recall/fetch: most results."},"cursor": {"type": "string", "description": "fetch: next-page cursor."},+ "refers_to": {+ "type": "object",+ "additionalProperties": false,+ "description": "recall/fetch: the local calendar dates the question is about, resolved against the Current Date & Time line. Set it whenever the question mentions or implies a time, in any language: \"yesterday\", \"last Saturday\", \"in March\", \"kal\", \"pichle hafte\", \"el viernes\". A single day has from == to. If a word can mean the past or the future (Hindi \"kal\"), cover both days. Prefer this over filter.observed_after/observed_before: those drop every memory recorded on another day, this only ranks the matching days first.",+ "properties": {+ "from": {"type": "string", "format": "date", "description": "First local date, YYYY-MM-DD."},+ "to": {"type": "string", "format": "date", "description": "Last local date, YYYY-MM-DD, inclusive."}+ },+ "required": ["from", "to"]+ },"text": {"type": "string", "description": "learn: the learning, one self-contained sentence."},"kind": {"type": "string", "enum": ["preference", "fact", "procedure", "correction", "other"], "description": "learn: what kind of learning (default fact)."},"confidence": {"type": "number", "minimum": 0, "maximum": 1, "description": "learn: confidence (default 0.8)."},diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rsindex 5c494ef8a1..ddb21909d3 100644--- a/crates/openhuman-core/src/memory/tools_tests.rs+++ b/crates/openhuman-core/src/memory/tools_tests.rs@@ -554,3 +554,99 @@ async fn a_failed_learn_is_reported_to_the_model() {text(&learned));}++/// The reference engine, recording the date hint each read carried.+struct HintRecorder {+ inner: tinymemory_api::conformance::ReferenceEngine,+ hints: std::sync::Mutex<Vec<Option<tinymemory_api::TimeHint>>>,+}++#[async_trait]+impl tinymemory_api::MemoryEngine for HintRecorder {+ fn descriptor(&self) -> &tinymemory_api::EngineDescriptor {+ self.inner.descriptor()+ }+ async fn health(&self) -> tinymemory_api::EngineHealth {+ self.inner.health().await+ }+ async fn recall(+ &self,+ req: tinymemory_api::RecallRequest,+ ) -> tinymemory_api::Result<tinymemory_api::RecallAnswer> {+ self.hints.lock().unwrap().push(req.refers_to.clone());+ self.inner.recall(req).await+ }+ async fn fetch(+ &self,+ req: tinymemory_api::FetchRequest,+ ) -> tinymemory_api::Result<tinymemory_api::FetchPage> {+ self.hints.lock().unwrap().push(req.refers_to.clone());+ self.inner.fetch(req).await+ }+ async fn store(+ &self,+ item: tinymemory_api::StoreItem,+ ) -> tinymemory_api::Result<tinymemory_api::StoreReceipt> {+ self.inner.store(item).await+ }+ async fn forget(+ &self,+ target: tinymemory_api::ForgetTarget,+ ) -> tinymemory_api::Result<tinymemory_api::ForgetReport> {+ self.inner.forget(target).await+ }+ async fn list(+ &self,+ req: tinymemory_api::ListRequest,+ ) -> tinymemory_api::Result<tinymemory_api::ListPage> {+ self.inner.list(req).await+ }+}++#[tokio::test]+async fn refers_to_reaches_the_engine_in_the_users_time_zone() {+ let tmp = tempfile::tempdir().unwrap();+ let mut config = config_in(&tmp);+ config.user_timezone = Some("Asia/Kolkata".into());+ let engine = Arc::new(HintRecorder {+ inner: tinymemory_api::conformance::ReferenceEngine::new(),+ hints: std::sync::Mutex::new(Vec::new()),+ });+ crate::memory::engine::install_test_engine(&config.workspace_dir, engine.clone());++ let fetched = run_action(+ &config,+ &json!({"action": "fetch", "query": "dinner", "refers_to": {"from": "2026-10-03", "to": "2026-10-04"}}),+ &facts(),+ )+ .await;+ assert!(!fetched.is_error, "{}", text(&fetched));+ let recalled = run_action(+ &config,+ &json!({"action": "recall", "question": "dinner", "refers_to": {"from": "2026-10-03"}}),+ &facts(),+ )+ .await;+ assert!(!recalled.is_error, "{}", text(&recalled));+ let bad = run_action(+ &config,+ &json!({"action": "fetch", "query": "dinner", "refers_to": {"from": "last Saturday"}}),+ &facts(),+ )+ .await;+ assert!(bad.is_error, "a non-date is a model-visible error");++ let day = |d| chrono::NaiveDate::from_ymd_opt(2026, 10, d).unwrap();+ let hints = engine.hints.lock().unwrap().clone();+ assert_eq!(+ hints,+ vec![+ Some(+ tinymemory_api::TimeHint::new(day(3), day(4), Some("Asia/Kolkata".into())).unwrap()+ ),+ Some(+ tinymemory_api::TimeHint::new(day(3), day(3), Some("Asia/Kolkata".into())).unwrap()+ ),+ ]+ );+}diff --git a/crates/openhuman-core/src/memory/types.rs b/crates/openhuman-core/src/memory/types.rsindex 650bb62eeb..f3050798c6 100644--- a/crates/openhuman-core/src/memory/types.rs+++ b/crates/openhuman-core/src/memory/types.rs@@ -96,6 +96,20 @@ pub struct RecallParams {/// Most citations to return.#[serde(default)]pub limit: Option<usize>,+ /// The local days the question is about: memories from them rank+ /// first, nothing is dropped. Read in the user's time zone.+ #[serde(default)]+ pub refers_to: Option<RefersTo>,+}++/// Local calendar days (`YYYY-MM-DD`), inclusive; `to` defaults to `from`.+#[derive(Debug, Clone, Deserialize)]+pub struct RefersTo {+ /// First day.+ pub from: chrono::NaiveDate,+ /// Last day; the same as `from` for a single day.+ #[serde(default)]+ pub to: Option<chrono::NaiveDate>,}/// `memory_recall` result.@@ -127,6 +141,9 @@ pub struct FetchParams {/// Engine cursor from a previous page.#[serde(default)]pub cursor: Option<String>,+ /// The local days the query is about (see [`RecallParams::refers_to`]).+ #[serde(default)]+ pub refers_to: Option<RefersTo>,}/// `memory_fetch` result.