Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

chore: files changed crates/openhuman-core/src/memory/lifecycle/date_hint_tests.rs,crates/openhuman-

Steven Enamakel7daef930e47e
diff --git a/crates/openhuman-core/src/memory/lifecycle/date_hint_tests.rs b/crates/openhuman-core/src/memory/lifecycle/date_hint_tests.rs
deleted file mode 100644
index 8034ecb59d..0000000000
--- a/crates/openhuman-core/src/memory/lifecycle/date_hint_tests.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-use super::*;
-
-fn day(d: u32) -> NaiveDate {
- NaiveDate::from_ymd_opt(2026, 10, d).unwrap()
-}
-
-#[test]
-fn a_range_in_the_answer_is_a_hint_in_the_users_zone() {
- let hint = parse(
- "```json\n{\"from\":\"2026-10-06\",\"to\":\"2026-10-08\"}\n```",
- "Asia/Kolkata",
- )
- .expect("a hint");
- assert_eq!(
- hint,
- TimeHint::new(day(6), day(8), Some("Asia/Kolkata".into())).unwrap()
- );
- let single = parse("{\"from\":\"2026-10-03\"}", "UTC").expect("one day");
- assert_eq!((single.from, single.to), (day(3), day(3)));
-}
-
-#[test]
-fn no_date_or_nonsense_is_no_hint() {
- for answer in [
- "{\"from\":null,\"to\":null}",
- "no date here",
- "{\"from\":\"last Saturday\"}",
- "{\"from\":\"2026-10-08\",\"to\":\"2026-10-06\"}",
- "} {",
- ] {
- assert_eq!(parse(answer, "UTC"), None, "{answer}");
- }
-}
diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks.rs b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
index 3a56977c84..22c68e13bc 100644
--- a/crates/openhuman-core/src/memory/lifecycle/hooks.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/hooks.rs
@@ -9,11 +9,10 @@ use serde::Serialize;
use tinymemory_api::{Hit, ObservedActor, ThreadWindow, ToolCallRef, Turn};
use tinymemory_tools::layout::identity::ResolvedIdentity;
use tinymemory_tools::lifecycle::turn::{
- self as native_turn, CitationSink, Clock, CompactionOptions, DateHintModel, EngineResolver,
- JobsSink, LoggedToolCall, PostTurn, PreTurn, PreTurnOptions, TurnHooks as NativeTurnHooks,
- TurnPack as NativeTurnPack,
+ self as native_turn, CitationSink, Clock, CompactionOptions, EngineResolver, JobsSink,
+ LoggedToolCall, PreTurnOptions, TurnHooks as NativeTurnHooks, TurnPack as NativeTurnPack,
};
-use tinymemory_tools::{AgentMemory, BackgroundJob};
+use tinymemory_tools::{AgentMemory, BackgroundJob, Compaction, PostTurn, PreTurn};
use crate::config::Config;
use crate::core::runtime::{CoreContext, DispatchCtx};
@@ -300,7 +299,7 @@ pub(crate) async fn compaction_work(
let hooks = turn_hooks(ctx, &Arc::new(config.clone()), identity, thread_id);
hooks
.compaction(
- native_turn::Compaction {
+ Compaction {
thread_id: thread_id.to_owned(),
dropped,
focus: None,
diff --git a/crates/openhuman-core/src/memory/lifecycle/mod.rs b/crates/openhuman-core/src/memory/lifecycle/mod.rs
index c6a1b184ce..e0acb033c6 100644
--- a/crates/openhuman-core/src/memory/lifecycle/mod.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/mod.rs
@@ -21,7 +21,6 @@ pub mod jobs;
pub(crate) mod prefetch;
pub mod sender;
pub mod views;
-pub mod window;
use std::sync::Arc;
@@ -49,18 +48,6 @@ pub fn policy(recall: &MemoryRecallConfig) -> RecallPolicy {
}
}
-/// A policy that recalls nothing: the turn is logged, no section is read.
-#[must_use]
-pub fn log_only(policy: RecallPolicy) -> RecallPolicy {
- RecallPolicy {
- learnings_limit: 0,
- brain_limit: 0,
- history_limit: 0,
- team_limit: 0,
- ..policy
- }
-}
-
/// `identity`'s memory on `engine` under `config`'s policy.
pub fn agent_memory_on(
engine: Arc<dyn MemoryEngine>,
diff --git a/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs b/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs
index 6c04b6fbc8..938f7ca285 100644
--- a/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/mod_tests.rs
@@ -23,7 +23,7 @@ fn the_policy_mirrors_the_recall_config() {
"a zero budget is clamped, never refused"
);
- let quiet = log_only(default.clone());
+ let quiet = default.log_only();
assert_eq!(
(
quiet.learnings_limit,
diff --git a/crates/openhuman-core/src/memory/lifecycle/window.rs b/crates/openhuman-core/src/memory/lifecycle/window.rs
deleted file mode 100644
index bbcf2d7720..0000000000
--- a/crates/openhuman-core/src/memory/lifecycle/window.rs
+++ /dev/null
@@ -1,117 +0,0 @@
-//! The first turn of a thread still verbatim in a turn's prompt, kept live
-//! across the turn: the turn's memory reads leave the thread out from there,
-//! and a compaction during the turn moves it forward.
-
-use std::collections::HashSet;
-use std::hash::{DefaultHasher, Hash, Hasher};
-use std::sync::atomic::{AtomicU32, Ordering};
-use std::sync::Mutex;
-
-/// The first turn of a thread still verbatim in a turn's prompt.
-///
-/// The pre-turn step sets it from the transcript's last checkpoint. When a
-/// compaction during the turn folds more of the thread, the compaction hook
-/// advances it past the user turns it folded, so the turn's next memory read
-/// can return them. It never passes the turn's own index: the message being
-/// answered, and the reply being written, stay out.
-///
-/// Folded messages are counted by position, not by text, so two identical
-/// messages are two turns. The same slice folded again moves nothing, and a
-/// slice that starts where the turn's first one did (the transcript folded
-/// again from the start) is counted from the turn's starting point rather
-/// than on top of what was already counted. Both rules can only count too
-/// little, never too much: the window may stay short, never pass a turn still
-/// in the prompt.
-#[derive(Debug)]
-pub struct InPromptFrom {
- from: AtomicU32,
- start: u32,
- ceiling: u32,
- folds: Mutex<Folds>,
-}
-
-/// The slices a turn's compactions folded, by fingerprint.
-#[derive(Debug, Default)]
-struct Folds {
- seen: HashSet<u64>,
- first_head: Option<u64>,
-}
-
-fn fingerprint<'a>(texts: impl IntoIterator<Item = &'a str>) -> u64 {
- let mut hasher = DefaultHasher::new();
- for text in texts {
- text.hash(&mut hasher);
- }
- hasher.finish()
-}
-
-impl InPromptFrom {
- /// Starts at `from`, never past `ceiling`: the turn's own user-turn index.
- #[must_use]
- pub fn new(from: u32, ceiling: u32) -> Self {
- let start = from.min(ceiling);
- Self {
- from: AtomicU32::new(start),
- start,
- ceiling,
- folds: Mutex::default(),
- }
- }
-
- /// The first turn still in the prompt.
- #[must_use]
- pub fn get(&self) -> u32 {
- self.from.load(Ordering::Acquire)
- }
-
- /// Moves past the user messages one compaction folded, in transcript
- /// order: two memory turns (the message and its reply) for each. Returns
- /// the new value.
- pub fn advance_past<I>(&self, folded_user_texts: I) -> u32
- where
- I: IntoIterator,
- I::Item: AsRef<str>,
- {
- let texts: Vec<I::Item> = folded_user_texts.into_iter().collect();
- let from = self.get();
- let Some(first) = texts.first() else {
- return from;
- };
- let mut folds = self
- .folds
- .lock()
- .unwrap_or_else(std::sync::PoisonError::into_inner);
- if !folds
- .seen
- .insert(fingerprint(texts.iter().map(AsRef::as_ref)))
- {
- return from;
- }
- let head = fingerprint([first.as_ref()]);
- let step = u32::try_from(texts.len())
- .unwrap_or(u32::MAX)
- .saturating_mul(2);
- let next = match folds.first_head {
- None => {
- folds.first_head = Some(head);
- from.saturating_add(step)
- }
- // The transcript folded again from the start of the turn.
- Some(first_head) if first_head == head => from.max(self.start.saturating_add(step)),
- Some(_) => from.saturating_add(step),
- }
- .min(self.ceiling);
- self.from.store(next, Ordering::Release);
- tracing::debug!(
- from,
- next,
- folded = texts.len(),
- "[memory:window] compaction moved the in-prompt window"
- );
- next
- }
-}
-
-#[cfg(test)]
-#[path = "window_tests.rs"]
-mod tests;
diff --git a/crates/openhuman-core/src/memory/lifecycle/window_tests.rs b/crates/openhuman-core/src/memory/lifecycle/window_tests.rs
deleted file mode 100644
index 8dd95fb52c..0000000000
--- a/crates/openhuman-core/src/memory/lifecycle/window_tests.rs
+++ /dev/null
@@ -1,50 +0,0 @@
-use super::*;
-
-#[test]
-fn starts_where_the_pre_turn_step_put_it_and_never_past_the_turn() {
- assert_eq!(InPromptFrom::new(6, 20).get(), 6);
- assert_eq!(InPromptFrom::new(30, 20).get(), 20);
-}
-
-#[test]
-fn a_fold_moves_it_two_turns_per_folded_user_message() {
- let window = InPromptFrom::new(6, 20);
- assert_eq!(
- window.advance_past(["first question", "second question"]),
- 10
- );
- assert_eq!(window.get(), 10);
- assert_eq!(window.advance_past(["third question"]), 12);
- assert_eq!(window.advance_past(Vec::<String>::new()), 12);
-}
-
-#[test]
-fn identical_messages_are_separate_turns() {
- let window = InPromptFrom::new(0, 40);
- assert_eq!(window.advance_past(["yes", "yes"]), 4);
- // A later fold holding the same text is new turns too.
- assert_eq!(window.advance_past(["ok", "yes"]), 8);
-}
-
-#[test]
-fn the_same_slice_folded_again_moves_nothing() {
- let window = InPromptFrom::new(0, 40);
- assert_eq!(window.advance_past(["a", "b"]), 4);
- assert_eq!(window.advance_past(["c"]), 6);
- assert_eq!(window.advance_past(["c"]), 6);
-}
-
-#[test]
-fn a_fold_from_the_start_of_the_turn_is_counted_from_there() {
- let window = InPromptFrom::new(2, 40);
- assert_eq!(window.advance_past(["a", "b"]), 6);
- // The transcript folded again from its start, one message further:
- // three messages past the turn's start, not five past the last value.
- assert_eq!(window.advance_past(["a", "b", "c"]), 8);
-}
-
-#[test]
-fn it_stops_at_the_turn_being_answered() {
- let window = InPromptFrom::new(16, 20);
- assert_eq!(window.advance_past(["a", "b", "c", "d", "e"]), 20);
-}