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/prefetch.rs,crates/openhuman-core/sr

Steven Enamakeld22eb9111e6a
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
index 789542a409..bf30cf4f08 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
@@ -8,7 +8,9 @@ use std::sync::{Arc, LazyLock};
use std::time::Duration;
use futures::future::BoxFuture;
-use tinymemory_tools::prefetch::{Limits, PrefetchRuntime, TurnCache, TurnCacheRegistry, WorkerPool};
+use tinymemory_tools::prefetch::{
+ Limits, PrefetchRuntime, TurnCache, TurnCacheRegistry, WorkerPool,
+};
use crate::config::Config;
use crate::core::runtime::{slot_for, DispatchCtx};
@@ -134,7 +136,10 @@ fn completed(cache: &Cache, key: &Key) -> Option<TurnPack> {
fn enqueue(cache: Arc<Cache>, key: Key, work: Work) {
tracing::debug!(thread_id = %key.thread, agent_id = %key.identity.agent_id, compaction = key.compaction, "[memory:prefetch] enqueue refresh");
- cache.0.enqueue(key, Box::pin(async move { work.await.map(|pack| pack.native) }));
+ cache.0.enqueue(
+ key,
+ Box::pin(async move { work.await.map(|pack| pack.native) }),
+ );
}
/// Returns the last completed pack immediately, then logs this user turn and
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
index 99397946c0..a79d9e0da3 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
@@ -64,7 +64,16 @@ async fn held_refresh_returns_immediately_and_later_turn_reads_completed_context
);
release.notify_one();
drain(&cache, &key).await;
- assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("later result"));
+ let cached = completed(&cache, &key).expect("completed background pack");
+ assert_eq!(cached.markdown.matches(CACHED_NOTICE).count(), 1);
+ assert_eq!(
+ cached.tokens,
+ pack("later result").tokens + tinymemory_tools::recall::estimate_tokens(CACHED_NOTICE)
+ );
+ assert_eq!(
+ cached_markdown(&cache, &key).as_deref(),
+ Some("later result")
+ );
}
#[tokio::test]
@@ -291,7 +300,10 @@ async fn credential_invalidation_removes_ready_and_rejects_late_inflight_results
drain(&cache, &key).await;
release.notify_one();
tokio::task::yield_now().await;
- assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("new credentials"));
+ assert_eq!(
+ cached_markdown(&cache, &key).as_deref(),
+ Some("new credentials")
+ );
}
struct HeldEngine {