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: files changed crates/openhuman-core/src/memory/tools_tests.rs,crates/openhuman-core/src/memor
Steven Enamakel748c53bc1c1f
diff --git a/crates/openhuman-core/src/memory/tools_activity_tests.rs b/crates/openhuman-core/src/memory/tools_activity_tests.rsnew file mode 100644index 0000000000..8b354f6846--- /dev/null+++ b/crates/openhuman-core/src/memory/tools_activity_tests.rs@@ -0,0 +1,86 @@+use super::*;++/// The memory activity a tool call raises reaches the chat its own turn is in:+/// the `MemoryRecalled` event carries the turn's thread and client, taken from+/// the run context the tool was dispatched with, and a call outside a chat turn+/// raises it unrouted. (A `learn` is queued and published off the turn, so it+/// is never routed.)+#[tokio::test]+async fn memory_activity_carries_the_calling_turns_chat() {+ crate::core::bus::init().await.expect("bus init");+ let mut rx = crate::core::bus::BUS.get().unwrap().receiver();+ let tmp = tempfile::tempdir().unwrap();+ let config = config_in(&tmp);+ let _engine = bind_reference(&config);+ let tool = MemoryTool::new(Arc::new(config.clone()));++ for memory_text in ["routed marker question", "unrouted marker question"] {+ let learned = tool+ .execute(json!({"action": "learn", "text": memory_text}))+ .await+ .unwrap();+ assert!(!learned.is_error, "{}", text(&learned));+ }+ crate::memory::tool_writes::drain(&config).await;++ let context = crate::agent::tinyagents::host::run_context::tool_context_with_approval(+ crate::security::approval::ApprovalTurnContext::chat(+ crate::security::approval::ApprovalChatContext {+ thread_id: "thread-activity".into(),+ client_id: "client-activity".into(),+ request_id: None,+ },+ ),+ );+ let routed = tool+ .execute_with_context(+ json!({"action": "recall", "question": "routed marker question"}),+ ToolCallOptions::default(),+ Some(&context),+ )+ .await+ .unwrap();+ assert!(!routed.is_error, "{}", text(&routed));+ let unrouted = tool+ .execute(json!({"action": "recall", "question": "unrouted marker question"}))+ .await+ .unwrap();+ assert!(!unrouted.is_error, "{}", text(&unrouted));+ let expected_routed_hits = serde_json::from_str::<Value>(&text(&routed)).unwrap()["items"]+ .as_u64()+ .unwrap();+ let expected_unrouted_hits = serde_json::from_str::<Value>(&text(&unrouted)).unwrap()["items"]+ .as_u64()+ .unwrap();+ assert!(expected_routed_hits > 0, "the seeded memory must be recalled");+ assert!(expected_unrouted_hits > 0, "the seeded memory must be recalled");++ // The bus is process-wide: match our own events by the question text.+ let mut seen = std::collections::HashMap::new();+ while seen.len() < 2 {+ match tokio::time::timeout(std::time::Duration::from_secs(5), rx.recv()).await {+ Ok(Some(DomainEvent::MemoryRecalled {+ query,+ thread_id,+ client_id,+ hit_count,+ })) if query.contains("marker question") => {+ seen.insert(query, (thread_id, client_id, hit_count));+ }+ Ok(Some(_)) => continue,+ other => panic!("expected both MemoryRecalled events, got {other:?}"),+ }+ }+ assert_eq!(+ seen["routed marker question"],+ (+ Some("thread-activity".into()),+ Some("client-activity".into()),+ expected_routed_hits as usize,+ )+ );+ assert_eq!(+ seen["unrouted marker question"],+ (None, None, expected_unrouted_hits as usize)+ );+}diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rsindex e3e61d27f2..ac5679c106 100644--- a/crates/openhuman-core/src/memory/tools_tests.rs+++ b/crates/openhuman-core/src/memory/tools_tests.rs@@ -668,87 +668,5 @@ async fn learning_is_durably_queued_even_when_the_backend_refuses_writes() {assert_eq!(super::super::tool_writes::drain(&config).await, 0);}-/// The memory activity a tool call raises reaches the chat its own turn is in:-/// the `MemoryRecalled` event carries the turn's thread and client, taken from-/// the run context the tool was dispatched with, and a call outside a chat turn-/// raises it unrouted. (A `learn` is queued and published off the turn, so it-/// is never routed.)-#[tokio::test]-async fn memory_activity_carries_the_calling_turns_chat() {- crate::core::bus::init().await.expect("bus init");- let mut rx = crate::core::bus::BUS.get().unwrap().receiver();- let tmp = tempfile::tempdir().unwrap();- let config = config_in(&tmp);- let _engine = bind_reference(&config);- let tool = MemoryTool::new(Arc::new(config.clone()));-- for memory_text in ["routed marker question", "unrouted marker question"] {- let learned = tool- .execute(json!({"action": "learn", "text": memory_text}))- .await- .unwrap();- assert!(!learned.is_error, "{}", text(&learned));- }- super::super::tool_writes::drain(&config).await;-- let context = crate::agent::tinyagents::host::run_context::tool_context_with_approval(- crate::security::approval::ApprovalTurnContext::chat(- crate::security::approval::ApprovalChatContext {- thread_id: "thread-activity".into(),- client_id: "client-activity".into(),- request_id: None,- },- ),- );- let routed = tool- .execute_with_context(- json!({"action": "recall", "question": "routed marker question"}),- ToolCallOptions::default(),- Some(&context),- )- .await- .unwrap();- assert!(!routed.is_error, "{}", text(&routed));- let unrouted = tool- .execute(json!({"action": "recall", "question": "unrouted marker question"}))- .await- .unwrap();- assert!(!unrouted.is_error, "{}", text(&unrouted));- let expected_routed_hits = serde_json::from_str::<Value>(&text(&routed)).unwrap()["items"]- .as_u64()- .unwrap();- let expected_unrouted_hits = serde_json::from_str::<Value>(&text(&unrouted)).unwrap()["items"]- .as_u64()- .unwrap();- assert!(expected_routed_hits > 0, "the seeded memory must be recalled");- assert!(expected_unrouted_hits > 0, "the seeded memory must be recalled");-- // The bus is process-wide: match our own events by the question text.- let mut seen = std::collections::HashMap::new();- while seen.len() < 2 {- match tokio::time::timeout(std::time::Duration::from_secs(5), rx.recv()).await {- Ok(Some(DomainEvent::MemoryRecalled {- query,- thread_id,- client_id,- hit_count,- })) if query.contains("marker question") => {- seen.insert(query, (thread_id, client_id, hit_count));- }- Ok(Some(_)) => continue,- other => panic!("expected both MemoryRecalled events, got {other:?}"),- }- }- assert_eq!(- seen["routed marker question"],- (- Some("thread-activity".into()),- Some("client-activity".into()),- expected_routed_hits as usize,- )- );- assert_eq!(- seen["unrouted marker question"],- (None, None, expected_unrouted_hits as usize)- );-}+#[path = "tools_activity_tests.rs"]+mod activity_tests;