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/tool_writes_tests.rs,crates/openhuman-core/src

Steven Enamakel097e86708f93
diff --git a/crates/openhuman-core/src/memory/tool_writes_tests.rs b/crates/openhuman-core/src/memory/tool_writes_tests.rs
index 273fa854de..7e79e7029f 100644
--- a/crates/openhuman-core/src/memory/tool_writes_tests.rs
+++ b/crates/openhuman-core/src/memory/tool_writes_tests.rs
@@ -58,6 +58,10 @@ pub(crate) fn enqueue(
}
}
+pub(crate) fn queued_for(config: &Config, facts: &CallFacts) -> tinymemory_api::Result<Vec<Entry>> {
+ super::read_at(&super::queue_path(config, &facts.reach.at))
+}
+
fn facts(config: &Config) -> CallFacts {
CallFacts::of(
config,
diff --git a/crates/openhuman-core/src/memory/tools_tests.rs b/crates/openhuman-core/src/memory/tools_tests.rs
index 02e2c8f9b1..bd7933c215 100644
--- a/crates/openhuman-core/src/memory/tools_tests.rs
+++ b/crates/openhuman-core/src/memory/tools_tests.rs
@@ -120,6 +120,55 @@ async fn every_action_reports_memory_off_as_a_tool_error() {
}
}
+#[tokio::test]
+async fn queued_writes_work_without_an_available_engine_but_not_when_explicitly_disabled() {
+ let tmp = tempfile::tempdir().unwrap();
+ let config = config_in(&tmp);
+ assert!(!crate::memory::engine::switched_off(&config));
+ assert!(
+ !crate::memory::engine::is_on(&config),
+ "the fixture has no credential or installed engine"
+ );
+ let facts = CallFacts::gather(&config, None);
+ let tool = MemoryTool::new(Arc::new(config.clone()));
+ let learned = tool
+ .execute(json!({"action":"learn","text":"queued while offline"}))
+ .await
+ .unwrap();
+ let forgotten = tool
+ .execute(json!({"action":"forget","ids":["offline-item"]}))
+ .await
+ .unwrap();
+ assert!(!learned.is_error, "learn: {}", text(&learned));
+ assert!(!forgotten.is_error, "forget: {}", text(&forgotten));
+ let pending = crate::memory::tool_writes::tests::queued_for(&config, &facts).unwrap();
+ assert_eq!(
+ pending.len(),
+ 2,
+ "both operations must be durable in the outbox"
+ );
+
+ let mut disabled = config.clone();
+ disabled.components.memory = false;
+ let disabled_tool = MemoryTool::new(Arc::new(disabled.clone()));
+ for args in [
+ json!({"action":"learn","text":"must not queue"}),
+ json!({"action":"forget","ids":["offline-item"]}),
+ ] {
+ let result = disabled_tool.execute(args).await.unwrap();
+ assert!(result.is_error, "explicit disable must reject the write");
+ }
+ assert!(
+ crate::memory::tool_writes::tests::queued_for(
+ &disabled,
+ &CallFacts::gather(&disabled, None)
+ )
+ .unwrap()
+ .is_empty(),
+ "disabled memory must not append to the pending outbox"
+ );
+}
+
#[tokio::test]
async fn bad_arguments_and_unknown_actions_are_model_visible_errors() {
let tmp = tempfile::tempdir().unwrap();