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(memory): add tests for backfill and lifecycle hooks
Steven Enamakel39cea70aba26
diff --git a/crates/openhuman-core/src/memory/backfill_tests.rs b/crates/openhuman-core/src/memory/backfill_tests.rsindex 0cda546244..71060cfd5e 100644--- a/crates/openhuman-core/src/memory/backfill_tests.rs+++ b/crates/openhuman-core/src/memory/backfill_tests.rs@@ -109,6 +109,7 @@ async fn stores_past_chats_once_and_skips_what_live_logging_took() {// The lifecycle logged live-thread's second turn (user index 2).let identity = MemoryIdentity::agent(MAIN_AGENT).resolve(&config);crate::memory::lifecycle::hooks::pre_turn(+ &crate::core::runtime::DispatchCtx::ambient(),&config,&identity,crate::memory::lifecycle::hooks::PreTurnInput {diff --git a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rsindex ccabfdbbb1..b1e7fb9b66 100644--- a/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs+++ b/crates/openhuman-core/src/memory/lifecycle/hooks_tests.rs@@ -78,7 +78,7 @@ async fn pre_turn_logs_the_user_turn_and_injects_what_memory_holds() {.unwrap();let identity = MemoryIdentity::agent("orchestrator").resolve(&config);- let pack = pre_turn(&config, &identity, input("t1", 0, "what colour do I like?"))+ let pack = pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &identity, input("t1", 0, "what colour do I like?")).await.expect("a pack");assert!(pack.markdown.contains("teal"), "{}", pack.markdown);@@ -115,7 +115,7 @@ async fn recall_off_still_logs_and_logging_off_still_recalls() {config.memory.recall.enabled = false;let quiet = MemoryIdentity::agent("a").resolve(&config);assert!(- pre_turn(&config, &quiet, input("t", 0, "when do deploys happen?"))+ pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &quiet, input("t", 0, "when do deploys happen?")).await.is_none());@@ -129,7 +129,7 @@ async fn recall_off_still_logs_and_logging_off_still_recalls() {config.memory.recall.enabled = true;config.memory.conversations.enabled = false;let reader = MemoryIdentity::agent("a").resolve(&config);- let pack = pre_turn(&config, &reader, input("t", 2, "when do deploys happen?")).await;+ let pack = pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &reader, input("t", 2, "when do deploys happen?")).await;assert!(pack.expect("a pack").markdown.contains("Fridays"));assert_eq!(stored(&engine, MetaFilter::kinds([ItemKind::Conversation]))@@ -141,7 +141,7 @@ async fn recall_off_still_logs_and_logging_off_still_recalls() {config.memory.recall.enabled = false;let none = MemoryIdentity::agent("a").resolve(&config);- assert!(pre_turn(&config, &none, input("t", 4, "hi"))+ assert!(pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &none, input("t", 4, "hi")).await.is_none());}@@ -151,7 +151,7 @@ async fn pre_turn_without_an_engine_runs_the_turn_without_a_pack() {let tmp = tempfile::tempdir().unwrap();let config = config_in(&tmp);let identity = MemoryIdentity::agent("a").resolve(&config);- assert!(pre_turn(&config, &identity, input("t", 0, "hello"))+ assert!(pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &identity, input("t", 0, "hello")).await.is_none());post_turn(&config, &identity, reply("t", 1, "hi")).await;@@ -201,6 +201,7 @@ async fn compaction_recalls_from_the_dropped_turns() {bind_reference(&config);let identity = MemoryIdentity::agent("a").resolve(&config);let _ = pre_turn(+ &crate::core::runtime::DispatchCtx::ambient(),&config,&identity,input("t", 0, "the project codename is Heron"),@@ -226,7 +227,7 @@ async fn an_out_of_credits_recall_tells_the_turn_memory_is_unavailable() {crate::memory::test_fixtures::RefusingEngine::out_of_credits().bind(&config);let identity = MemoryIdentity::agent("orchestrator").resolve(&config);- let pack = pre_turn(&config, &identity, input("t", 0, "what colour do I like?"))+ let pack = pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &identity, input("t", 0, "what colour do I like?")).await.expect("a refused recall still gives the turn a notice");@@ -254,7 +255,7 @@ async fn an_unreachable_engine_is_named_as_unreachable() {.bind(&config);let identity = MemoryIdentity::agent("orchestrator").resolve(&config);- let pack = pre_turn(&config, &identity, input("t", 0, "hello"))+ let pack = pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &identity, input("t", 0, "hello")).await.expect("notice");@@ -276,7 +277,7 @@ async fn an_engine_fault_that_is_not_account_wide_injects_nothing() {.bind(&config);let identity = MemoryIdentity::agent("orchestrator").resolve(&config);- assert!(pre_turn(&config, &identity, input("t", 0, "hello"))+ assert!(pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &identity, input("t", 0, "hello")).await.is_none());}@@ -360,6 +361,7 @@ async fn a_turn_pack_stays_within_its_budget_against_a_large_store() {let identity = MemoryIdentity::agent("orchestrator").resolve(&config);let pack = pre_turn(+ &crate::core::runtime::DispatchCtx::ambient(),&config,&identity,input("t-large", 0, "when does the Lisbon release ship?"),@@ -400,6 +402,7 @@ async fn a_resumed_session_pack_stays_within_one_budget_and_repeats_nothing() {// line is distinct, so a repeat can only be one item injected twice.for turn in 0..6u32 {let _ = pre_turn(+ &crate::core::runtime::DispatchCtx::ambient(),&config,&identity,input(@@ -424,7 +427,7 @@ async fn a_resumed_session_pack_stays_within_one_budget_and_repeats_nothing() {let mut resumed = input("t-resumed", 12, "when does the Lisbon release ship?");resumed.resumed_after_compaction = true;resumed.in_prompt_from = 12;- let pack = pre_turn(&config, &identity, resumed).await.expect("a pack");+ let pack = pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &identity, resumed).await.expect("a pack");eprintln!("resumed session: pack {} tokens (budget {}), repeated lines {}",pack.tokens,@@ -459,6 +462,7 @@ async fn a_resumed_session_without_logging_still_opens_with_the_thread() {let _engine = bind_reference(&config);let identity = MemoryIdentity::agent("orchestrator").resolve(&config);let _ = pre_turn(+ &crate::core::runtime::DispatchCtx::ambient(),&config,&identity,input("t-quiet", 0, "where is the Lisbon offsite?"),@@ -476,7 +480,7 @@ async fn a_resumed_session_without_logging_still_opens_with_the_thread() {let mut resumed = input("t-quiet", 2, "remind me where the offsite is");resumed.resumed_after_compaction = true;resumed.in_prompt_from = 2;- let pack = pre_turn(&config, &reader, resumed).await.expect("a pack");+ let pack = pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &reader, resumed).await.expect("a pack");assert!(pack.markdown.contains("Alfama hotel"), "{}", pack.markdown);assert!(repeated_lines(&pack.markdown).is_empty());}@@ -487,7 +491,7 @@ async fn a_blank_turn_is_refused_without_a_pack_with_or_without_logging() {let mut config = config_in(&tmp);let engine = bind_reference(&config);let identity = MemoryIdentity::agent("orchestrator").resolve(&config);- assert!(pre_turn(&config, &identity, input("t-blank", 0, " "))+ assert!(pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &identity, input("t-blank", 0, " ")).await.is_none());assert!(@@ -499,12 +503,12 @@ async fn a_blank_turn_is_refused_without_a_pack_with_or_without_logging() {config.memory.conversations.enabled = false;let reader = MemoryIdentity::agent("orchestrator").resolve(&config);- assert!(pre_turn(&config, &reader, input("t-blank", 2, " "))+ assert!(pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &reader, input("t-blank", 2, " ")).await.is_none());let mut resumed = input(" ", 4, "where were we?");resumed.resumed_after_compaction = true;- assert!(pre_turn(&config, &reader, resumed).await.is_none());+ assert!(pre_turn(&crate::core::runtime::DispatchCtx::ambient(),&config, &reader, resumed).await.is_none());}/// With `date_hint` on, the turn's text goes to the chat model with the date@@ -536,6 +540,7 @@ async fn a_date_hint_asks_the_model_in_the_users_zone_and_never_costs_the_pack()let identity = MemoryIdentity::agent("orchestrator").resolve(&config);let pack = pre_turn(+ &crate::core::runtime::DispatchCtx::ambient(),&config,&identity,input("t-dated", 0, "what colour did I pick last Saturday?"),