Skip to content

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

chore: files changed tests/memory_v2_e2e.rs

Steven Enamakelb369447512ce
diff --git a/tests/memory_v2_e2e.rs b/tests/memory_v2_e2e.rs
index f9bb4d85cb..b6b0848ccf 100644
--- a/tests/memory_v2_e2e.rs
+++ b/tests/memory_v2_e2e.rs
@@ -369,7 +369,11 @@ async fn memory_is_off_when_signed_out() {
json!({ "consent": true }),
),
("openhuman.memory_sources_sync", json!({})),
- ("openhuman.memory_context_refresh", json!({})),
+ ("openhuman.memory_pack_preview", json!({ "query": "anything" })),
+ ("openhuman.memory_agents_list", json!({})),
+ ("openhuman.memory_brain_sources", json!({})),
+ ("openhuman.memory_brain_ingest", json!({ "text": "a doc" })),
+ ("openhuman.memory_jobs_run", json!({})),
("openhuman.memory_import_start", json!({ "consent": true })),
];
for (method, params) in off_calls {
@@ -377,15 +381,15 @@ async fn memory_is_off_when_signed_out() {
}
// Local settings and state still answer while memory is off.
- let conversations = f.ok("openhuman.memory_conversations_get", json!({})).await;
- assert_eq!(conversations["enabled"], json!(true));
+ let policy = f.ok("openhuman.memory_policy_get", json!({})).await;
+ assert_eq!(policy["log_conversations"], json!(true));
assert_eq!(
f.ok("openhuman.memory_sources_list", json!({})).await["sources"],
json!([])
);
assert_eq!(
- f.ok("openhuman.memory_context_get", json!({})).await["markdown"],
- json!("")
+ f.ok("openhuman.memory_jobs_list", json!({})).await["pending"],
+ json!([])
);
assert_eq!(
f.ok("openhuman.memory_import_scan", json!({})).await["found"],
@@ -814,46 +818,46 @@ async fn memory_is_isolated_per_account() {
// ---------------------------------------------------------------------------
#[tokio::test]
-async fn conversations_get_and_set_round_trip() {
+async fn policy_get_and_set_round_trip() {
let f = Fixture::new(true).await;
- let defaults = f.ok("openhuman.memory_conversations_get", json!({})).await;
- assert_eq!(defaults["enabled"], json!(true));
- assert_eq!(defaults["batch_turns"], json!(4));
- assert_eq!(defaults["idle_secs"], json!(120));
- assert_eq!(defaults["recent"], json!([]));
+ let defaults = f.ok("openhuman.memory_policy_get", json!({})).await;
+ assert_eq!(defaults["log_conversations"], json!(true));
+ assert_eq!(defaults["recall"]["enabled"], json!(true));
+ assert_eq!(defaults["recall"]["budget_tokens"], json!(1200));
+ assert_eq!(defaults["root"], json!("root"));
+ assert_eq!(defaults["host_bound"], json!(false));
let updated = f
.ok(
- "openhuman.memory_conversations_set",
- json!({ "enabled": false, "batch_turns": 2, "idle_secs": 30 }),
+ "openhuman.memory_policy_set",
+ json!({ "log_conversations": false, "budget_tokens": 600, "team_limit": 0 }),
)
.await;
- assert_eq!(updated["enabled"], json!(false));
- assert_eq!(updated["batch_turns"], json!(2));
- assert_eq!(updated["idle_secs"], json!(30));
+ assert_eq!(updated["log_conversations"], json!(false));
+ assert_eq!(updated["recall"]["budget_tokens"], json!(600));
+ assert_eq!(updated["recall"]["team_limit"], json!(0));
// Persisted: a fresh read sees it, and a partial set keeps the rest.
let partial = f
.ok(
- "openhuman.memory_conversations_set",
- json!({ "enabled": true }),
+ "openhuman.memory_policy_set",
+ json!({ "log_conversations": true }),
)
.await;
- assert_eq!(partial["enabled"], json!(true));
- assert_eq!(partial["batch_turns"], json!(2));
- let again = f.ok("openhuman.memory_conversations_get", json!({})).await;
- assert_eq!(again["idle_secs"], json!(30));
+ assert_eq!(partial["log_conversations"], json!(true));
+ assert_eq!(partial["recall"]["budget_tokens"], json!(600));
+ let again = f.ok("openhuman.memory_policy_get", json!({})).await;
+ assert_eq!(again["recall"]["team_limit"], json!(0));
for bad in [
- json!({ "batch_turns": 0 }),
- json!({ "batch_turns": 1000 }),
- json!({ "idle_secs": 0 }),
- json!({ "idle_secs": 10_000_000 }),
+ json!({ "budget_tokens": 1 }),
+ json!({ "brain_limit": 1000 }),
+ json!({ "pre_turn_timeout_ms": 0 }),
+ json!({ "batch_turns": 4 }),
] {
assert_eq!(
- f.code("openhuman.memory_conversations_set", bad.clone())
- .await,
+ f.code("openhuman.memory_policy_set", bad.clone()).await,
"INVALID_REQUEST",
"{bad}"
);
@@ -1139,59 +1143,69 @@ async fn sources_add_sync_list_and_remove() {
// ---------------------------------------------------------------------------
#[tokio::test]
-async fn context_get_set_and_refresh() {
+async fn brain_pack_preview_and_jobs_round_trip() {
let f = Fixture::new(true).await;
- let initial = f.ok("openhuman.memory_context_get", json!({})).await;
- assert_eq!(initial["enabled"], json!(true));
- assert_eq!(initial["interval_mins"], json!(360));
- assert_eq!(initial["budget_tokens"], json!(2000));
- assert_eq!(initial["markdown"], json!(""));
- assert!(initial["generated_at"].is_null());
-
- let set = f
+ let filed = f
.ok(
- "openhuman.memory_context_set",
- json!({ "enabled": true, "interval_mins": 30, "budget_tokens": 500 }),
+ "openhuman.memory_brain_ingest",
+ json!({ "text": "Standup is at nine every weekday", "source": "notion", "title": "Rituals" }),
)
.await;
- assert_eq!(set["interval_mins"], json!(30));
- assert_eq!(set["budget_tokens"], json!(500));
- let partial = f
- .ok("openhuman.memory_context_set", json!({ "enabled": false }))
- .await;
- assert_eq!(partial["enabled"], json!(false));
- assert_eq!(partial["interval_mins"], json!(30));
- f.ok("openhuman.memory_context_set", json!({ "enabled": true }))
- .await;
+ assert_eq!(filed["source"], json!("notion"));
+ assert_eq!(
+ f.code(
+ "openhuman.memory_brain_ingest",
+ json!({ "text": "x", "path": "/also" })
+ )
+ .await,
+ "INVALID_REQUEST"
+ );
- for bad in [
- json!({ "interval_mins": 1 }),
- json!({ "budget_tokens": 10 }),
- json!({ "budget_tokens": 1_000_000 }),
- ] {
- assert_eq!(
- f.code("openhuman.memory_context_set", bad.clone()).await,
- "INVALID_REQUEST",
- "{bad}"
- );
- }
+ let sources = f.ok("openhuman.memory_brain_sources", json!({})).await;
+ assert_eq!(sources["sources"][0]["source"], json!("notion"), "{sources}");
+ let found = f
+ .ok(
+ "openhuman.memory_brain_search",
+ json!({ "query": "standup", "source": "notion" }),
+ )
+ .await;
+ assert_eq!(found["hits"].as_array().unwrap().len(), 1, "{found}");
- // refresh compiles a brief from what memory holds and persists it.
- f.learn("The team standup is at nine every weekday").await;
- let refreshed = f.ok("openhuman.memory_context_refresh", json!({})).await;
- assert!(refreshed["generated_at"].is_string(), "{refreshed}");
- assert!(refreshed["tokens"].as_u64().unwrap_or(0) > 0, "{refreshed}");
- let markdown = refreshed["markdown"].as_str().unwrap_or_default();
- assert!(
- !markdown.trim().is_empty(),
- "context.md has content: {refreshed}"
+ // The pack a turn about standups would get carries the brain document.
+ f.learn("The user prefers short answers").await;
+ let preview = f
+ .ok(
+ "openhuman.memory_pack_preview",
+ json!({ "query": "when is standup?" }),
+ )
+ .await;
+ assert_eq!(preview["mode"], json!("turn"));
+ let markdown = preview["pack"]["markdown"].as_str().unwrap_or_default();
+ assert!(markdown.contains("nine"), "{preview}");
+ let session = f.ok("openhuman.memory_pack_preview", json!({})).await;
+ assert_eq!(session["mode"], json!("session"));
+
+ // The ingest queued its source's belief build; the hosted engine builds on
+ // its own schedule, so running it sends nothing and reports `scheduled`.
+ let jobs = f.ok("openhuman.memory_jobs_list", json!({})).await;
+ assert_eq!(jobs["pending"].as_array().unwrap().len(), 1, "{jobs}");
+ let ran = f.ok("openhuman.memory_jobs_run", json!({})).await;
+ assert_eq!(ran["runs"][0]["outcome"], json!("scheduled"), "{ran}");
+ let after = f.ok("openhuman.memory_jobs_list", json!({})).await;
+ assert_eq!(after["pending"], json!([]));
+ assert_eq!(after["history"][0]["outcome"], json!("scheduled"));
+ assert_eq!(
+ f.code("openhuman.memory_jobs_run", json!({ "id": "nope" })).await,
+ "INVALID_REQUEST"
);
- let read_back = f.ok("openhuman.memory_context_get", json!({})).await;
- assert_eq!(read_back["markdown"], refreshed["markdown"]);
- assert_eq!(read_back["generated_at"], refreshed["generated_at"]);
- assert_eq!(read_back["budget_tokens"], json!(500));
+ let gone = f
+ .ok("openhuman.memory_brain_forget", json!({ "source": "notion" }))
+ .await;
+ assert_eq!(gone["forgotten"], json!(1), "{gone}");
+ let agents = f.ok("openhuman.memory_agents_list", json!({})).await;
+ assert_eq!(agents["root"], json!("root"));
}
#[tokio::test]
@@ -1338,7 +1352,7 @@ async fn explore_drills_down_and_items_get_reads_whole() {
// ---------------------------------------------------------------------------
#[tokio::test]
-async fn agent_namespaces_keep_memory_apart_over_rpc() {
+async fn memory_nodes_keep_memory_apart_over_rpc() {
let f = Fixture::new(true).await;
let learn_at = |text: &'static str, namespace: &'static str| {
let f = &f;
@@ -1407,25 +1421,11 @@ async fn agent_namespaces_keep_memory_apart_over_rpc() {
// A malformed node is refused.
let refused = f
.call(
- "openhuman.memory_context_get",
- json!({ "namespace": "not a node" }),
+ "openhuman.memory_items_list",
+ json!({ "filter": { "reach": { "at": "not a node" } } }),
)
.await;
assert!(refused.get("error").is_some(), "{refused}");
-
- // Each node compiles its own context.md.
- let brief = f
- .ok(
- "openhuman.memory_context_refresh",
- json!({ "namespace": "agent:researcher" }),
- )
- .await;
- assert_eq!(brief["namespace"], json!("agent:researcher"));
- let text = brief["markdown"].as_str().unwrap();
- assert!(text.contains("arxiv") && text.contains("Sam"), "{brief}");
- assert!(!text.contains("British"), "{brief}");
- let root = f.ok("openhuman.memory_context_get", json!({})).await;
- assert_eq!(root["namespace"], json!("root"));
}
#[tokio::test]
@@ -1490,6 +1490,9 @@ async fn memory_v2_registers_exactly_the_documented_methods() {
"engines_list",
"engine_get",
"engine_set",
+ "policy_get",
+ "policy_set",
+ "pack_preview",
"recall",
"fetch",
"learn",
@@ -1497,17 +1500,19 @@ async fn memory_v2_registers_exactly_the_documented_methods() {
"items_list",
"explore",
"items_get",
- "conversations_get",
- "conversations_set",
+ "agents_list",
"conversations_backfill_status",
"conversations_backfill_start",
+ "brain_sources",
+ "brain_search",
+ "brain_ingest",
+ "brain_forget",
"sources_list",
"sources_add",
"sources_remove",
"sources_sync",
- "context_get",
- "context_refresh",
- "context_set",
+ "jobs_list",
+ "jobs_run",
"import_scan",
"import_start",
"import_status",
@@ -1531,6 +1536,11 @@ async fn memory_v2_registers_exactly_the_documented_methods() {
"openhuman.tree_summarizer_run",
"openhuman.memory_sources_get",
"openhuman.memory_sources_update",
+ "openhuman.memory_context_get",
+ "openhuman.memory_context_refresh",
+ "openhuman.memory_context_set",
+ "openhuman.memory_conversations_get",
+ "openhuman.memory_conversations_set",
] {
let response = f.call(method, json!({})).await;
let message = response["error"]["message"].as_str().unwrap_or_default();