Skip to content

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

test(todo): use local scratch lock and store helpers in todo tests

Steven Enamakele3baca484ab1
diff --git a/crates/openhuman-core/src/agent/tools/todo_tests.rs b/crates/openhuman-core/src/agent/tools/todo_tests.rs
index 367256f877..1aac2494a8 100644
--- a/crates/openhuman-core/src/agent/tools/todo_tests.rs
+++ b/crates/openhuman-core/src/agent/tools/todo_tests.rs
@@ -3,14 +3,19 @@ use serde_json::{json, Value};
use tinyagents_graph::todos::{TodoItem, TodoStatus};
/// Serialize tests that share the process-global scratch store. Same lock
-/// as `todos::ops` — otherwise the two test modules race under `cargo test`'s
-/// thread pool.
+/// process-global scratch store.
+static SCRATCH_TEST_LOCK: tokio::sync::Mutex<()> = tokio::sync::Mutex::const_new(());
+
fn scratch_lock() -> tokio::sync::MutexGuard<'static, ()> {
- crate::agent::todos::ops::scratch_test_lock()
+ SCRATCH_TEST_LOCK.blocking_lock()
}
async fn scratch_lock_async() -> tokio::sync::MutexGuard<'static, ()> {
- crate::agent::todos::ops::scratch_test_lock_async().await
+ SCRATCH_TEST_LOCK.lock().await
+}
+
+fn todo_store(workspace_dir: &std::path::Path) -> std::sync::Arc<dyn tinyagents_harness::store::Store> {
+ crate::agent::session_store::stores_or_ephemeral(workspace_dir).kv
}
/// A fresh on-disk workspace root for one test's `FileStore`-backed todo
@@ -23,7 +28,7 @@ fn test_workspace() -> std::path::PathBuf {
}
async fn reset_scratch(workspace_dir: &std::path::Path) {
- crate::agent::todos::ops::clear(workspace_dir, &TodoScope::Scratch)
+ tinyagents_graph::todos::store::clear(&todo_store(workspace_dir), "_scratch_")
.await
.expect("clear scratch");
}
@@ -221,7 +226,7 @@ async fn a_legacy_session_keyed_list_is_migrated_forward_once() {
id: parent.session_id.clone(),
};
let item = TodoItem::with_status("carried over", TodoStatus::InProgress);
- crate::agent::todos::ops::replace(&workspace_dir, &legacy_scope, vec![item])
+ tinyagents_graph::todos::store::replace(&todo_store(&workspace_dir), legacy_scope.key(), vec![item])
.await
.unwrap();
@@ -243,7 +248,7 @@ async fn a_legacy_session_keyed_list_is_migrated_forward_once() {
let thread_scope = TodoScope::Session {
id: "thread-legacy".into(),
};
- let migrated = crate::agent::todos::ops::list(&workspace_dir, &thread_scope)
+ let migrated = tinyagents_graph::todos::store::list(&todo_store(&workspace_dir), thread_scope.key())
.await
.unwrap();
assert_eq!(migrated.items.len(), 1);
@@ -258,19 +263,19 @@ async fn sessions_do_not_see_each_other_and_a_list_survives_across_turns() {
let b = TodoScope::Session {
id: "sess-b".into(),
};
- crate::agent::todos::ops::clear(&workspace_dir, &a)
+ tinyagents_graph::todos::store::clear(&todo_store(&workspace_dir), a.key())
.await
.unwrap();
- crate::agent::todos::ops::clear(&workspace_dir, &b)
+ tinyagents_graph::todos::store::clear(&todo_store(&workspace_dir), b.key())
.await
.unwrap();
let item = TodoItem::with_status("only in a", TodoStatus::InProgress);
- crate::agent::todos::ops::replace(&workspace_dir, &a, vec![item])
+ tinyagents_graph::todos::store::replace(&todo_store(&workspace_dir), a.key(), vec![item])
.await
.unwrap();
- let a_again = crate::agent::todos::ops::list(&workspace_dir, &a)
+ let a_again = tinyagents_graph::todos::store::list(&todo_store(&workspace_dir), a.key())
.await
.unwrap();
assert_eq!(
@@ -279,7 +284,7 @@ async fn sessions_do_not_see_each_other_and_a_list_survives_across_turns() {
"a later turn of the same session reads it back"
);
assert_eq!(a_again.thread_id, "sess-a");
- assert!(crate::agent::todos::ops::list(&workspace_dir, &b)
+ assert!(tinyagents_graph::todos::store::list(&todo_store(&workspace_dir), b.key())
.await
.unwrap()
.items
diff --git a/vendor/tinyagents b/vendor/tinyagents
index 7e659ebb53..5fa61fe8db 160000
--- a/vendor/tinyagents
+++ b/vendor/tinyagents
@@ -1 +1 @@
-Subproject commit 7e659ebb53fa5469fbcf17b24ccb6d2d4f8835c9
+Subproject commit 5fa61fe8db7a42fc55b0021a2caa6b2b7806f8ce