Skip to content

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

test(memory): drop citation tests moved to web_chat

Steven Enamakelfedd63680024
diff --git a/crates/openhuman-core/src/memory/tools_agent_tests.rs b/crates/openhuman-core/src/memory/tools_agent_tests.rs
index f2bda2f40c..a0389bb5d5 100644
--- a/crates/openhuman-core/src/memory/tools_agent_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_agent_tests.rs
@@ -1,69 +1,4 @@
use super::*;
-use crate::core::runtime::{context::CoreContext, ContextOverlay, DomainSet};
-use crate::tools::toolpacks::ToolGroups;
-use std::collections::HashSet;
-use tinymemory_api::ItemKind;
-
-fn agent(parent: &Arc<CoreContext>, id: &str) -> Arc<CoreContext> {
- parent.derive_with(
- ContextOverlay::new(
- crate::config::Config::default(),
- DomainSet::kernel(),
- ToolGroups::none(),
- )
- .session_agent(id),
- )
-}
-
-fn citation(id: &str) -> TurnCitation {
- TurnCitation {
- id: id.to_string(),
- key: "learning".to_string(),
- namespace: None,
- score: None,
- timestamp: String::new(),
- snippet: String::new(),
- }
-}
-
-#[tokio::test]
-async fn turn_citations_stay_with_the_agent_that_recorded_them() {
- let root = CoreContext::for_test(DomainSet::full(), None);
- let alpha = agent(&root, "alpha");
- let beta = agent(&root, "beta");
- let thread = "shared-thread";
-
- {
- let scope_ctx = crate::core::runtime::DispatchCtx::new(Arc::clone(&alpha));
-
- record_pack_citations(&scope_ctx, thread, vec![citation("alpha-cite")]);
- };
- {
- let scope_ctx = crate::core::runtime::DispatchCtx::new(Arc::clone(&beta));
-
- record_pack_citations(&scope_ctx, thread, vec![citation("beta-cite")]);
- };
-
- let from_beta = {
- let scope_ctx = crate::core::runtime::DispatchCtx::new(beta);
-
- take_turn_citations(&scope_ctx, thread)
- };
- let from_alpha = {
- let scope_ctx = crate::core::runtime::DispatchCtx::new(alpha);
-
- take_turn_citations(&scope_ctx, thread)
- };
-
- assert_eq!(
- from_alpha.iter().map(|c| c.id.as_str()).collect::<Vec<_>>(),
- ["alpha-cite"]
- );
- assert_eq!(
- from_beta.iter().map(|c| c.id.as_str()).collect::<Vec<_>>(),
- ["beta-cite"]
- );
-}
/// A tool context for a run that acts on memory as `identity`.
fn tool_context_acting_as(
@@ -101,32 +36,3 @@ fn gather_acts_as_the_identity_the_run_carries() {
assert!(bare.reach.at.is_root());
}
-#[test]
-fn turn_citations_are_capped_and_deduplicated() {
- let citation = |n: usize| tinymemory_api::Citation {
- id: tinymemory_api::ItemId(format!("cite-{n}")),
- kind: ItemKind::Learning,
- snippet: "s".repeat(1000),
- score: Some(0.5),
- meta: MemoryMeta::default(),
- };
- let thread = "thread-cap";
- let many: Vec<_> = (0..MAX_TURN_CITATIONS + 10).map(citation).collect();
- record_turn_citations(&DispatchCtx::ambient(), thread, &many);
- record_turn_citations(&DispatchCtx::ambient(), thread, &many[..2]);
- record_turn_citations(&DispatchCtx::ambient(), thread, &[]);
- let drained = take_turn_citations(&DispatchCtx::ambient(), thread);
- assert_eq!(drained.len(), MAX_TURN_CITATIONS);
- assert_eq!(
- drained
- .iter()
- .map(|c| c.id.clone())
- .collect::<HashSet<_>>()
- .len(),
- MAX_TURN_CITATIONS
- );
- assert!(
- drained[0].snippet.chars().count() <= crate::web_chat::TURN_CITATION_SNIPPET_CHARS
- );
- assert_eq!(drained[0].key, "learning");
-}
diff --git a/crates/openhuman-core/src/memory/tools_read_tests.rs b/crates/openhuman-core/src/memory/tools_read_tests.rs
index 7501395970..e192b87666 100644
--- a/crates/openhuman-core/src/memory/tools_read_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_read_tests.rs
@@ -119,7 +119,7 @@ async fn recall_returns_evidence_and_leaves_the_calling_thread_out() {
out.get("answer").is_none(),
"recall writes no answer of its own"
);
- let cites = take_turn_citations(&DispatchCtx::ambient(), &live);
+ let cites = crate::web_chat::citations::take_turn_citations(&DispatchCtx::ambient(), &live);
assert_eq!(cites.len(), 1, "{cites:?}");
}
diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rs
index c090a94638..0b10253b29 100644
--- a/crates/openhuman-core/src/memory/tools_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_tests.rs
@@ -188,10 +188,10 @@ async fn recall_fetch_and_forget_round_trip_and_recall_records_citations() {
)
.await;
assert!(!recalled.is_error, "{}", text(&recalled));
- let cites = take_turn_citations(&ambient(), "thread-citations");
+ let cites = crate::web_chat::citations::take_turn_citations(&ambient(), "thread-citations");
assert!(cites.iter().any(|c| c.id == id), "{cites:?}");
assert!(
- take_turn_citations(&ambient(), "thread-citations").is_empty(),
+ crate::web_chat::citations::take_turn_citations(&ambient(), "thread-citations").is_empty(),
"draining empties the thread's citations"
);