Skip to content

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

test(embed): assert transcripts through the workspace store

Steven Enamakel867e43b5b526
diff --git a/crates/openhuman-embed/tests/harness_embed.rs b/crates/openhuman-embed/tests/harness_embed.rs
index 892092381b..b159411624 100644
--- a/crates/openhuman-embed/tests/harness_embed.rs
+++ b/crates/openhuman-embed/tests/harness_embed.rs
@@ -226,10 +226,6 @@ fn a_harness_runs_a_turn_against_the_provider_it_was_given() {
assert_eq!(harness.agent().id(), "harness");
assert_eq!(harness.runtime().workspace_dir(), harness.workspace_dir());
assert_eq!(harness.runtime().agent_ids(), vec!["harness".to_string()]);
- assert!(
- harness.agent().transcripts_dir().is_dir(),
- "the harness agent's transcripts were written"
- );
// A second harness — a second runtime — in this process must be
// refused rather than silently sharing process-global core state.
diff --git a/crates/openhuman-embed/tests/isolation_state.rs b/crates/openhuman-embed/tests/isolation_state.rs
index 7d28c5983c..3a6fa9b841 100644
--- a/crates/openhuman-embed/tests/isolation_state.rs
+++ b/crates/openhuman-embed/tests/isolation_state.rs
@@ -30,6 +30,16 @@ fn transcript_files(dir: &std::path::Path) -> Vec<std::path::PathBuf> {
.unwrap_or_default()
}
+/// Whether `agent` has a root transcript for the test thread in its own store
+/// under the workspace.
+fn has_transcript(agent: &Agent) -> bool {
+ tinyagents_session::port::WorkspaceStores::open(agent.workspace_dir(), agent.id())
+ .expect("the agent's workspace store")
+ .transcripts()
+ .root_for_thread(SESSION)
+ .is_some()
+}
+
fn skill_tools() -> AgentDefinitionSpec {
AgentDefinitionSpec::new().tools(ToolScopeSpec::Named(vec!["create_skill".to_string()]))
}
@@ -109,12 +119,12 @@ fn agents_on_one_workspace_keep_their_own_state() {
);
}
- // ── transcripts land under each agent's own directory ──
+ // ── transcripts land in each agent's own store ──
assert_ne!(a.transcripts_dir(), b.transcripts_dir());
assert!(a.transcripts_dir().starts_with(a.home_dir()));
assert!(b.transcripts_dir().starts_with(b.home_dir()));
- assert!(!transcript_files(a.transcripts_dir()).is_empty());
- assert!(!transcript_files(b.transcripts_dir()).is_empty());
+ assert!(has_transcript(&a), "a's turns are stored under a");
+ assert!(has_transcript(&b), "b's turns are stored under b");
assert!(
transcript_files(&a.workspace_dir().join("session_raw")).is_empty(),
"nothing is written to the shared transcript directory"
diff --git a/crates/openhuman-embed/tests/runtime_agents.rs b/crates/openhuman-embed/tests/runtime_agents.rs
index 46a6b3bc11..d1d94b2d47 100644
--- a/crates/openhuman-embed/tests/runtime_agents.rs
+++ b/crates/openhuman-embed/tests/runtime_agents.rs
@@ -404,18 +404,21 @@ fn one_runtime_hosts_independently_configured_agents() {
let b_body: serde_json::Value = serde_json::from_slice(&b_reqs[0].body).unwrap();
assert_eq!(a_body["model"], "alpha-model");
assert_eq!(b_body["model"], "beta-model");
- // Transcripts are keyed by agent and live in the agent's own
- // directory, and a thread resumes its own history.
- let listing = |dir: &std::path::Path| -> Vec<String> {
- std::fs::read_dir(dir)
- .expect("transcript dir")
- .flatten()
- .map(|e| e.file_name().to_string_lossy().into_owned())
- .collect()
+ // Transcripts are keyed by agent and live in the agent's own store
+ // under the workspace, and a thread resumes its own history.
+ let listing = |agent_id: &str, session_id: &str| -> Vec<String> {
+ tinyagents_session::port::WorkspaceStores::open(&workspace_dir, agent_id)
+ .expect("the agent's workspace store")
+ .transcripts()
+ .thread_transcripts(session_id, None)
+ .map(|found| found.roots.into_iter().map(|root| root.stem).collect())
+ .unwrap_or_default()
};
assert!(
!workspace_dir.join("session_raw").exists()
- || listing(&workspace_dir.join("session_raw")).is_empty(),
+ || std::fs::read_dir(workspace_dir.join("session_raw"))
+ .map(|mut entries| entries.next().is_none())
+ .unwrap_or(true),
"no agent writes to the shared transcript directory"
);
// Asserted against names the writer itself produced, not a shape
@@ -427,7 +430,7 @@ fn one_runtime_hosts_independently_configured_agents() {
// to mint `{unix_ts}_{agent}` stems — so it can no longer match.
for (agent, session_id) in [(&alpha, &a1.session_id), (&beta, &b0.session_id)] {
let agent_id = agent.id();
- let transcripts = listing(agent.transcripts_dir());
+ let transcripts = listing(agent_id, session_id);
let transcript = transcripts
.iter()
.find(|f| f.starts_with(&format!("{session_id}-")))
@@ -443,10 +446,7 @@ fn one_runtime_hosts_independently_configured_agents() {
// a substring would also be satisfied by an agent id that
// happened to appear in the session key, and would not fail if
// the agent scope were dropped from the stem altogether.
- let stem = transcript
- .strip_suffix(".jsonl")
- .expect("a transcript file name ends in .jsonl");
- let component = stem
+ let component = transcript
.rsplit('.')
.next()
.expect("rsplit always yields at least one component");