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 Enamakelb30403fabf70
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
index 13d1b6a38a..8e0a09b67f 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch.rs
@@ -16,7 +16,6 @@ use tinymemory_tools::layout::identity::ResolvedIdentity;
use super::hooks::{self, TurnPack};
-const MAX_PACK_BYTES: usize = 64 * 1024;
static WORKERS: LazyLock<WorkerPool> = LazyLock::new(|| WorkerPool::new(8));
static CACHES: LazyLock<TurnCacheRegistry<Key>> = LazyLock::new(TurnCacheRegistry::default);
@@ -36,15 +35,6 @@ impl PrefetchRuntime for HostRuntime {
}
}
-fn pack_fits(pack: &TurnPack) -> bool {
- serde_json::to_vec(pack)
- .ok()
- .zip(serde_json::to_vec(&pack.citations).ok())
- .is_some_and(|(pack, citations)| {
- pack.len().saturating_add(citations.len()) <= MAX_PACK_BYTES
- })
-}
-
#[derive(Clone, Hash, PartialEq, Eq)]
struct Key {
workspace: PathBuf,
diff --git a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
index 20dc9101b5..8214ce598f 100644
--- a/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
+++ b/crates/openhuman-core/src/memory/lifecycle/prefetch_tests.rs
@@ -28,6 +28,14 @@ async fn drain(cache: &Cache, key: &Key) {
.expect("worker completed");
}
+fn cached_markdown(cache: &Cache, key: &Key) -> Option<String> {
+ completed(cache, key).map(|pack| {
+ pack.markdown
+ .split_once("\n\n")
+ .map_or(pack.markdown.clone(), |(_, body)| body.to_owned())
+ })
+}
+
#[tokio::test]
async fn held_refresh_returns_immediately_and_later_turn_reads_completed_context() {
let _guard = TEST_LOCK.lock().await;
@@ -53,7 +61,7 @@ async fn held_refresh_returns_immediately_and_later_turn_reads_completed_context
);
release.notify_one();
drain(&cache, &key).await;
- assert_eq!(completed(&cache, &key).unwrap().markdown, "later result");
+ assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("later result"));
}
#[tokio::test]
@@ -170,7 +178,7 @@ async fn invalidation_rejects_late_results_and_preserves_bounded_pending_logs()
.resolve(&crate::memory::scope::identity_pins(&config));
let key = Key::new(&config, &identity, "t", false);
let cache = Arc::new(Cache::default());
- CACHES.lock().unwrap().push(Arc::downgrade(&cache));
+ CACHES.register(&cache.0);
let release = Arc::new(tokio::sync::Notify::new());
let started = Arc::new(tokio::sync::Notify::new());
let held = release.clone();
@@ -208,7 +216,7 @@ async fn invalidation_rejects_late_results_and_preserves_bounded_pending_logs()
Box::pin(async { Some(pack("fresh")) }),
);
drain(&cache, &key).await;
- assert_eq!(completed(&cache, &key).unwrap().markdown, "fresh");
+ assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("fresh"));
}
#[tokio::test]
@@ -226,7 +234,7 @@ async fn expiration_failure_and_oversized_packs_are_not_reused() {
Box::pin(async { Some(pack("good")) }),
);
drain(&cache, &key).await;
- assert_eq!(completed(&cache, &key).unwrap().markdown, "good");
+ assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("good"));
enqueue(
cache.clone(),
key.clone(),
@@ -248,7 +256,7 @@ async fn credential_invalidation_removes_ready_and_rejects_late_inflight_results
.resolve(&crate::memory::scope::identity_pins(&config));
let key = Key::new(&config, &identity, "t", false);
let cache = Arc::new(Cache::default());
- CACHES.lock().unwrap().push(Arc::downgrade(&cache));
+ CACHES.register(&cache.0);
enqueue(
cache.clone(),
key.clone(),
@@ -269,7 +277,7 @@ async fn credential_invalidation_removes_ready_and_rejects_late_inflight_results
}),
);
started.notified().await;
- assert_eq!(completed(&cache, &key).unwrap().markdown, "private");
+ assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("private"));
invalidate_all();
assert!(completed(&cache, &key).is_none());
enqueue(
@@ -280,7 +288,7 @@ 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!(completed(&cache, &key).unwrap().markdown, "new credentials");
+ assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("new credentials"));
}
struct HeldEngine {
@@ -472,7 +480,7 @@ async fn queued_work_keeps_the_callers_core_context() {
),
);
drain(&cache, &key).await;
- assert_eq!(completed(&cache, &key).unwrap().markdown, "scoped");
+ assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("scoped"));
})
.await;
}
@@ -513,7 +521,7 @@ fn runtime_shutdown_releases_worker_and_pending_work() {
Box::pin(async { Some(pack("later")) }),
);
drain(&cache, &key).await;
- assert_eq!(completed(&cache, &key).unwrap().markdown, "later");
+ assert_eq!(cached_markdown(&cache, &key).as_deref(), Some("later"));
});
}