Skip to content

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

test(session_store): cover sqlite agent isolation

Steven Enamakel30108784cef7
diff --git a/crates/openhuman-rpc/src/session_store/README.md b/crates/openhuman-rpc/src/session_store/README.md
index cc7ac5554e..b571524ff5 100644
--- a/crates/openhuman-rpc/src/session_store/README.md
+++ b/crates/openhuman-rpc/src/session_store/README.md
@@ -48,4 +48,4 @@ database.
| File | Contents |
| --- | --- |
| [`mod.rs`](mod.rs) | `install_for_host`, `provider_for_host`, `install_for_url`, `provider_for_url`, `install_for_saas`, and the URL resolution. |
-| [`mod_tests.rs`](mod_tests.rs) | Storage URL installation, environment URL resolution, an unusable URL, and the no-URL SaaS case. TinyAgents owns driver conformance tests. |
+| [`mod_tests.rs`](mod_tests.rs) | Storage URL installation, SQLite agent isolation, environment URL resolution, an unusable URL, and the no-URL SaaS case. TinyAgents owns driver conformance tests. |
diff --git a/crates/openhuman-rpc/src/session_store/mod_tests.rs b/crates/openhuman-rpc/src/session_store/mod_tests.rs
index 62c10ec96e..b0a69a2d78 100644
--- a/crates/openhuman-rpc/src/session_store/mod_tests.rs
+++ b/crates/openhuman-rpc/src/session_store/mod_tests.rs
@@ -53,6 +53,44 @@ async fn a_storage_url_installs_the_driver_backed_store() {
crate::core_host::agent::session_store::restore(previous);
}
+/// A SQLite storage URL installs the driver-backed store, and two agents on
+/// the same backend keep their turn states apart.
+async fn driver_backed_store_keeps_agents_apart(url: String, driver: &str) {
+ let _turn = SLOTS.lock().await;
+ let previous = crate::core_host::agent::session_store::installed();
+ let previous_backend = crate::core_host::storage::installed();
+ install_for_url(Some(url)).await.unwrap();
+
+ assert_eq!(
+ crate::core_host::storage::installed().map(|backend| backend.driver()),
+ Some(driver)
+ );
+ let provider = crate::core_host::agent::session_store::installed().unwrap();
+ let alice = provider.for_agent("alice");
+ alice
+ .turn_states
+ .put(&TurnState::started("t", "r", 8, "2026-01-01T00:00:00Z"))
+ .unwrap();
+ assert!(alice.turn_states.get("t").unwrap().is_some());
+ assert!(provider
+ .for_agent("bob")
+ .turn_states
+ .get("t")
+ .unwrap()
+ .is_none());
+
+ restore_backend(previous_backend);
+ crate::core_host::agent::session_store::restore(previous);
+}
+
+#[cfg(feature = "storage-sqlite")]
+#[tokio::test(flavor = "multi_thread")]
+async fn the_sqlite_backend_keeps_agents_apart() {
+ let dir = tempfile::tempdir().unwrap();
+ let url = format!("sqlite:{}", dir.path().join("sessions").display());
+ driver_backed_store_keeps_agents_apart(url, "sqlite").await;
+}
+
#[tokio::test]
async fn an_unusable_url_fails_the_boot() {
let _turn = SLOTS.lock().await;
diff --git a/tests/support/storage_drivers.rs b/tests/support/storage_drivers.rs
index 56f4544159..c71d182119 100644
--- a/tests/support/storage_drivers.rs
+++ b/tests/support/storage_drivers.rs
@@ -90,7 +90,7 @@ impl Case {
.unwrap_or_else(std::sync::PoisonError::into_inner);
let data_dir = tempfile::tempdir().expect("temp dir");
let Some(url) = driver.url(data_dir.path()) else {
- eprintln!("skipped {}: {}", driver.name(), "driver not compiled in");
+ eprintln!("skipped {}: driver not compiled in", driver.name());
return None;
};
let open_url = url.clone();