Skip to content

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

test(session): exercise legacy import through the session store provider

Steven Enamakel4a48e91cbf9f
diff --git a/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs b/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
index 2d709a3eb2..22da070374 100644
--- a/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/transcript_compat_tests.rs
@@ -24,6 +24,7 @@ use std::sync::{Arc, LazyLock, Mutex};
use serde_json::{json, Value};
use tinyagents_harness::testkit::ScriptedModel;
+use tinyagents_session::port::SessionStoreProvider;
use tinyagents_session::transcript::{SessionRef, TranscriptLocator};
use tinyinference_llm::message::{AssistantMessage, ContentBlock};
use tinyinference_llm::model::{ChatModel, ModelProfile, ModelResponse};
@@ -175,17 +176,21 @@ pub(super) fn model(responses: Vec<ModelResponse>, native: bool) -> Arc<Scripted
/// The transcript store of the workspace under `root`, one per root so that two
/// hosts built over the same root (two "processes") share the conversation.
-pub(super) fn store_locator(root: &Path) -> Arc<dyn TranscriptLocator> {
- static STORES: LazyLock<Mutex<HashMap<PathBuf, Arc<dyn TranscriptLocator>>>> =
+fn store_provider(root: &Path) -> Arc<dyn SessionStoreProvider> {
+ static STORES: LazyLock<Mutex<HashMap<PathBuf, Arc<dyn SessionStoreProvider>>>> =
LazyLock::new(Mutex::default);
let mut stores = STORES.lock().unwrap_or_else(|e| e.into_inner());
Arc::clone(
stores
.entry(root.to_path_buf())
- .or_insert_with(crate::storage::sessions::splice_fixture_tests::memory_locator),
+ .or_insert_with(crate::storage::sessions::splice_fixture_tests::memory_session_provider),
)
}
+pub(super) fn store_locator(root: &Path) -> Arc<dyn TranscriptLocator> {
+ store_provider(root).for_agent("fixture").transcripts
+}
+
pub(super) fn build_host(
root: &Path,
model: Arc<ScriptedModel>,
@@ -236,9 +241,9 @@ pub(super) fn classic_path(root: &Path, stem: &str) -> PathBuf {
/// Imports the classic files placed under the workspace's `session_raw/` into
/// the root's store, as the first start after an upgrade does.
pub(super) fn import_placed(root: &Path) {
- tinyagents_session::legacy::import_transcripts(
+ crate::storage::import::sessions::import_transcript_groups(
+ store_provider(root).as_ref(),
&root.join("workspace"),
- store_locator(root).as_ref(),
)
.expect("import the placed fixtures");
}
diff --git a/crates/openhuman-core/src/storage/sessions/splice_fixture_tests.rs b/crates/openhuman-core/src/storage/sessions/splice_fixture_tests.rs
index 0b1f9c60cb..589fd6a94d 100644
--- a/crates/openhuman-core/src/storage/sessions/splice_fixture_tests.rs
+++ b/crates/openhuman-core/src/storage/sessions/splice_fixture_tests.rs
@@ -2,6 +2,7 @@
use std::sync::Arc;
+use tinyagents_session::port::{AgentStorageFactory, DriverSessionStores, SessionStoreProvider};
use tinyagents_session::transcript::{TranscriptLocator, TranscriptMessage, TranscriptMeta};
/// A fresh transcript store over the driver ports on memory (the production
@@ -10,6 +11,21 @@ pub(crate) fn memory_locator() -> Arc<dyn TranscriptLocator> {
tinyagents_session::testkit::in_memory_transcript()
}
+/// A real driver-backed session provider over the TSD memory testkit. All
+/// agent IDs share this fixture's isolated scope so legacy transcript grouping
+/// can be exercised without weakening production scope selection.
+pub(crate) fn memory_session_provider() -> Arc<dyn SessionStoreProvider> {
+ use tinystoragedrivers_api::StorageBackend as _;
+
+ let backend = crate::storage::test_support::memory_backend();
+ let factory: AgentStorageFactory = Arc::new(move |_| {
+ let scope = tinystoragedrivers_types::Scope::new("transcript-fixture")?;
+ let storage = backend.for_scope(&scope)?;
+ Ok(tinyagents_storage_kit::ScopedStorage::new(storage, scope))
+ });
+ Arc::new(DriverSessionStores::new(factory).expect("driver session stores over testkit memory"))
+}
+
/// A thread's head transcript as the model reads it.
pub(crate) struct Head {
pub stem: String,
diff --git a/crates/openhuman-core/src/threads/transcript_host_tests.rs b/crates/openhuman-core/src/threads/transcript_host_tests.rs
index 778badb4ec..867516afc4 100644
--- a/crates/openhuman-core/src/threads/transcript_host_tests.rs
+++ b/crates/openhuman-core/src/threads/transcript_host_tests.rs
@@ -8,7 +8,7 @@
use std::sync::Arc;
-use crate::storage::sessions::splice_fixture_tests::memory_locator;
+use crate::storage::sessions::splice_fixture_tests::{memory_locator, memory_session_provider};
use tempfile::TempDir;
use tinyagents_session::transcript::view::{
project_records, project_thread_in, DisplayItem, ToolCallStatus,
@@ -314,8 +314,10 @@ fn calls_recorded_after_their_results_project_as_settled() {
],
);
- let locator = memory_locator();
- tinyagents_session::legacy::import_transcripts(dir.path(), locator.as_ref()).unwrap();
+ let provider = memory_session_provider();
+ let locator = provider.for_agent(crate::storage::sessions::DEFAULT_AGENT).transcripts;
+ crate::storage::import::sessions::import_transcript_groups(provider.as_ref(), dir.path())
+ .unwrap();
let items = project_thread_in(locator.as_ref(), thread, None, None)
.expect("transcript")
.items;