Skip to content

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

test(session-host): add transcript resume and splice fixtures

Steven Enamakelde1f1c8c0d7e
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 9eab6f4376..0bae22d5fa 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
@@ -469,7 +469,7 @@ fn assert_retired_tool_replay(identity_bound: bool) {
.turn("save this old conversation")
.await
.expect("archive turn");
- let archived = super::super::session_store::splice_fixture::head_of_full(
+ let archived = super::super::session_store::splice_fixture::head_of(
&store_locator(root.path()),
"retired-audio-thread",
);
@@ -523,7 +523,7 @@ fn assert_retired_tool_replay(identity_bound: bool) {
// remain intact in the durable transcript.
assert_eq!(
to_json(
- &super::super::session_store::splice_fixture::head_of_full(
+ &super::super::session_store::splice_fixture::head_of(
&store_locator(root.path()),
"retired-audio-thread",
)
diff --git a/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs b/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs
index abe9f1d2e4..9624aeb536 100644
--- a/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/transcript_resume_stable_tests.rs
@@ -1,55 +1,43 @@
//! A workspace written by the previous release resumes in place: resuming a
//! committed fixture neither renames, rewrites nor re-adopts anything, so the
-//! transcript stems and bytes on disk are exactly what the old binary left.
+//! transcripts the store holds are exactly what the import brought in.
use std::collections::BTreeMap;
use std::path::Path;
+use serde_json::Value;
use tinyinference_llm::model::ModelResponse;
use super::transcript_compat_tests::{
- build_host, model, place_fixture, run_async, session_raw, thread_id, Layout, SCENARIOS,
+ build_host, model, place_fixture, run_async, store_tree, thread_id, Layout, SCENARIOS,
};
-/// File name -> bytes for everything under the workspace's `session_raw/`.
-fn raw_tree(root: &Path) -> BTreeMap<String, Vec<u8>> {
- let mut out = BTreeMap::new();
- let Ok(entries) = std::fs::read_dir(session_raw(root)) else {
- return out;
- };
- for entry in entries.flatten() {
- let name = entry.file_name().to_string_lossy().into_owned();
- out.insert(name, std::fs::read(entry.path()).expect("read raw file"));
- }
- out
+fn tree(root: &Path, thread: &str, host: &crate::agent::OpenHumanSessionHost) -> BTreeMap<String, Value> {
+ store_tree(root, thread, host.session.as_ref().expect("bound session"))
}
#[test]
-fn resuming_a_committed_workspace_leaves_every_stem_and_byte_untouched() {
+fn resuming_a_committed_workspace_leaves_every_stem_and_row_untouched() {
for scenario in SCENARIOS
.iter()
.filter(|scenario| scenario.layout != Layout::Legacy)
{
run_async(async move {
let root = tempfile::tempdir().expect("tempdir");
+ let thread = thread_id(scenario.name);
let next = model(vec![ModelResponse::assistant("unused")], scenario.native);
- let mut host = build_host(
- root.path(),
- next,
- scenario.native,
- &thread_id(scenario.name),
- );
+ let mut host = build_host(root.path(), next, scenario.native, &thread);
let stem = host.session_id().expect("bound session id");
place_fixture(root.path(), scenario, &stem, "");
- let before = raw_tree(root.path());
+ let before = tree(root.path(), &thread, &host);
assert!(!before.is_empty(), "{}: fixture placed", scenario.name);
assert!(host.resume_bound_session().await.expect("resume"));
assert_eq!(
before,
- raw_tree(root.path()),
- "{}: resume must not rename, create or rewrite transcript files",
+ tree(root.path(), &thread, &host),
+ "{}: resume must not rename, create or rewrite transcripts",
scenario.name
);
});
@@ -72,21 +60,21 @@ fn a_legacy_workspace_is_adopted_once_and_the_next_process_resumes_in_place() {
let mut host = build_host(root.path(), next, scenario.native, &thread);
let stem = host.session_id().expect("bound session id");
place_fixture(root.path(), scenario, &stem, "");
- legacy_only = raw_tree(root.path());
+ legacy_only = tree(root.path(), &thread, &host);
assert!(host.resume_bound_session().await.expect("first resume"));
- after_first = raw_tree(root.path());
+ after_first = tree(root.path(), &thread, &host);
}
- // Adoption writes the session's own file and modifies no legacy file.
- for (name, bytes) in &legacy_only {
+ // Adoption writes the session's own transcript and modifies no legacy root.
+ for (name, rows) in &legacy_only {
assert_eq!(
after_first.get(name),
- Some(bytes),
- "legacy file {name} must stay byte-for-byte"
+ Some(rows),
+ "legacy root {name} must stay as imported"
);
}
assert!(
after_first.len() > legacy_only.len(),
- "adopted file written"
+ "adopted transcript written"
);
// A fresh process over the same workspace resumes without adopting again.
@@ -95,7 +83,7 @@ fn a_legacy_workspace_is_adopted_once_and_the_next_process_resumes_in_place() {
assert!(host.resume_bound_session().await.expect("second resume"));
assert_eq!(
after_first,
- raw_tree(root.path()),
+ tree(root.path(), &thread, &host),
"second resume must not re-adopt or rewrite anything"
);
});
diff --git a/crates/openhuman-core/src/agent/session_store/splice_fixture.rs b/crates/openhuman-core/src/agent/session_store/splice_fixture.rs
index 232c92fd69..ef912d504f 100644
--- a/crates/openhuman-core/src/agent/session_store/splice_fixture.rs
+++ b/crates/openhuman-core/src/agent/session_store/splice_fixture.rs
@@ -21,6 +21,8 @@ pub(crate) struct Head {
pub stem: String,
pub meta: TranscriptMeta,
pub messages: Vec<TranscriptMessage>,
+ /// The tool declarations last recorded with the transcript.
+ pub tools: Option<serde_json::Value>,
}
/// The single root transcript of `thread_id`.
@@ -43,6 +45,7 @@ pub(crate) fn head_of(locator: &Arc<dyn TranscriptLocator>, thread_id: &str) ->
stem: root.stem.clone(),
meta: session.meta,
messages: session.messages,
+ tools: session.tools,
}
}