Skip to content

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

refactor(threads): extract transcript host tests into a dedicated module

Steven Enamakel06f28ac58305
diff --git a/crates/openhuman-core/src/threads/transcript_host_tests.rs b/crates/openhuman-core/src/threads/transcript_host_tests.rs
index 11508632a6..826c5488f8 100644
--- a/crates/openhuman-core/src/threads/transcript_host_tests.rs
+++ b/crates/openhuman-core/src/threads/transcript_host_tests.rs
@@ -6,16 +6,31 @@
//! session codec and writer, and transcripts written before calls rode their
//! issuing row.
+use std::sync::Arc;
+
+use crate::agent::session_store::splice_fixture::memory_locator;
use tempfile::TempDir;
use tinyagents_session::transcript::view::{
- project_records, project_thread, DisplayItem, ToolCallStatus,
+ project_records, project_thread_in, DisplayItem, ToolCallStatus,
};
use tinyagents_session::transcript::TranscriptMessage;
-use tinyagents_session::transcript::{self, read_transcript_display};
+use tinyagents_session::transcript::{self, TranscriptLocator};
+
+/// A thread's display records, read back through the store port.
+fn display_of(locator: &Arc<dyn TranscriptLocator>, thread_id: &str) -> transcript::DisplaySessionTranscript {
+ locator
+ .root_for_thread(thread_id)
+ .expect("the thread has a root transcript")
+ .read_display()
+ .expect("read the display records")
+ .expect("display records")
+}
-/// Write a raw JSONL transcript (meta header + `body` lines) for `thread_id`.
+/// Write a raw classic JSONL transcript (meta header + `body` lines) for
+/// `thread_id`, the file layout older releases left behind.
fn write_raw(workspace: &std::path::Path, stem: &str, thread_id: &str, body: &[&str]) {
- let path = transcript::resolve_keyed_transcript_path(workspace, stem).expect("resolve");
+ let path = workspace.join("session_raw").join(format!("{stem}.jsonl"));
+ std::fs::create_dir_all(path.parent().unwrap()).expect("session_raw");
let mut buf = format!(
r#"{{"_meta":{{"version":1,"agent":"orchestrator","dispatcher":"xml","created":"2026-09-24T00:00:00Z","updated":"2026-09-24T00:00:10Z","turn_count":1,"input_tokens":0,"output_tokens":0,"cached_input_tokens":0,"charged_amount_usd":0.0,"thread_id":"{thread_id}"}}}}"#
);
@@ -46,8 +61,6 @@ fn text_dialect_tool_turn_projects_calls_on_their_issuing_row_as_settled() {
use tinytools_agent::dialect::NativeToolCall;
use tinytools_agent::dialect::{ToolResultEntry, TranscriptEntry};
- let dir = TempDir::new().unwrap();
-
// What the session driver persists for a text dialect: the conversation
// rendered through the dialect's replay form.
let conversation = vec![
@@ -178,14 +191,27 @@ fn text_dialect_tool_turn_projects_calls_on_their_issuing_row_as_settled() {
thread_id: Some("thr_xml".into()),
task_id: None,
};
- let path = transcript::resolve_keyed_transcript_path(dir.path(), "xml_orchestrator").unwrap();
- transcript::append_transcript_turn(&path, &[], &rows, &meta, usage.as_ref(), Some("req-xml"))
+ let locator = memory_locator();
+ locator
+ .open_stem("xml_orchestrator", meta.clone())
+ .unwrap()
+ .append_turn(transcript::TranscriptTurn {
+ prev: &[],
+ next: &rows,
+ meta: &meta,
+ turn_usage: usage.as_ref(),
+ request_id: Some("req-xml"),
+ tools: None,
+ })
.unwrap();
// The durable rows: the calls ride the issuing row, not the final answer.
- let persisted = transcript::read_transcript(&path).unwrap();
+ let persisted = locator
+ .open_stem("xml_orchestrator", meta.clone())
+ .unwrap()
+ .messages()
+ .unwrap();
let assistants: Vec<_> = persisted
- .messages
.iter()
.filter(|m| m.role.as_str() == "assistant")
.collect();
@@ -212,7 +238,7 @@ fn text_dialect_tool_turn_projects_calls_on_their_issuing_row_as_settled() {
);
// The projection: calls settled with their results, no raw results bubble.
- let display = read_transcript_display(&path).unwrap();
+ let display = display_of(&locator, "thr_xml");
let items = project_records(&display.records);
let calls: Vec<_> = items
.iter()
@@ -285,7 +311,9 @@ fn calls_recorded_after_their_results_project_as_settled() {
],
);
- let items = project_thread(dir.path(), thread)
+ let locator = memory_locator();
+ tinyagents_session::legacy::import_transcripts(dir.path(), locator.as_ref()).unwrap();
+ let items = project_thread_in(locator.as_ref(), thread, None, None)
.expect("transcript")
.items;
let calls: Vec<_> = items
@@ -326,7 +354,6 @@ fn tool_failure_metadata_round_trips_write_to_display_line() {
// Full write path: a failed tool TranscriptMessage stamped with failure metadata
// must serialise the additive `failure` line field and read back as a failed
// display message — proving the harness → transcript → projection seam.
- let dir = TempDir::new().unwrap();
let now = "2026-07-21T09:00:00Z".to_string();
let meta = transcript::TranscriptMeta {
session_id: None,
@@ -357,10 +384,14 @@ fn tool_failure_metadata_round_trips_write_to_display_line() {
});
let messages = vec![TranscriptMessage::user("do it"), tool_msg];
- let path = transcript::resolve_keyed_transcript_path(dir.path(), "700_orchestrator").unwrap();
- transcript::write_transcript(&path, &messages, &meta, None).unwrap();
+ let locator = memory_locator();
+ locator
+ .open_stem("700_orchestrator", meta.clone())
+ .unwrap()
+ .replace(&messages)
+ .unwrap();
- let display = read_transcript_display(&path).unwrap();
+ let display = display_of(&locator, "thr_rt");
let failed = display
.records
.iter()