Skip to content

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

test(relay): cover concurrent retries of one message

Steven Enamakel3f633fe820e8
diff --git a/crates/openhuman-core/src/channels/providers/relay/store_tests.rs b/crates/openhuman-core/src/channels/providers/relay/store_tests.rs
index b34786d9c6..be55b3aa54 100644
--- a/crates/openhuman-core/src/channels/providers/relay/store_tests.rs
+++ b/crates/openhuman-core/src/channels/providers/relay/store_tests.rs
@@ -70,3 +70,27 @@ async fn replies_are_recorded_and_seed_the_next_turn() {
assert_eq!(limited.len(), 1);
assert_eq!(limited[0].content, "hi\n\nthere", "the most recent rows");
}
+
+#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
+async fn concurrent_retries_of_one_message_record_it_once() {
+ let tmp = tempfile::tempdir().unwrap();
+ let p = params("race", "hello");
+ let thread = p.thread_id();
+ let mut tasks = Vec::new();
+ for _ in 0..8 {
+ let dir = tmp.path().to_path_buf();
+ let (p, thread) = (p.clone(), thread.clone());
+ tasks.push(tokio::spawn(async move {
+ record_inbound(&dir, &p, &thread).await
+ }));
+ }
+ let mut new = 0;
+ for task in tasks {
+ if task.await.unwrap() == Ok(Recorded::New) {
+ new += 1;
+ }
+ }
+ assert_eq!(new, 1, "exactly one concurrent retry is the new message");
+ let messages = crate::threads::store::get_messages(tmp.path().to_path_buf(), &thread).unwrap();
+ assert_eq!(messages.len(), 1);
+}