Skip to content

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

feat(embed): lay out each agent's transcripts under its own directory (#7032)

oxoxDev0f3441086691
diff --git a/crates/openhuman-embed/src/agent/layout.rs b/crates/openhuman-embed/src/agent/layout.rs
index cae19b97ac..fc77ad224f 100644
--- a/crates/openhuman-embed/src/agent/layout.rs
+++ b/crates/openhuman-embed/src/agent/layout.rs
@@ -8,10 +8,14 @@
//! config.toml, auth-profiles.json, core.token runtime-wide
//! workspace/
//! session_db/sessions.db runtime-wide run ledger
-//! agents/<id>/{SOUL.md, skills/} the agent's home
-//! session_raw/<ts>_<id>.jsonl its transcripts
+//! agents/<id>/{SOUL.md, skills/} the agent's home
+//! agents/<id>/session_raw/<stem>.jsonl its transcripts
//! agents/<id>/action/ its default action_dir
//! ```
+//!
+//! Transcripts an agent wrote to the shared `workspace/session_raw/` before
+//! this layout are still read, and are copied into the agent's directory
+//! before they are written to again.
use std::path::{Path, PathBuf};
@@ -36,7 +40,11 @@ impl AgentLayout {
Self {
home: workspace_dir.join("agents").join(id),
skills: workspace_dir.join("agents").join(id).join("skills"),
- transcripts: workspace_dir.join("session_raw"),
+ transcripts: openhuman_core::agent::session_store::agent_transcript_root(
+ workspace_dir,
+ id,
+ )
+ .join("session_raw"),
action_dir,
}
}
diff --git a/crates/openhuman-embed/src/agent/layout_tests.rs b/crates/openhuman-embed/src/agent/layout_tests.rs
index bdd50d425e..2534ecb790 100644
--- a/crates/openhuman-embed/src/agent/layout_tests.rs
+++ b/crates/openhuman-embed/src/agent/layout_tests.rs
@@ -6,7 +6,10 @@ fn layout_uses_agent_id_paths() {
let layout = AgentLayout::resolve(ws, "alpha", PathBuf::from("/r/a"));
assert_eq!(layout.home, Path::new("/r/workspace/agents/alpha"));
assert_eq!(layout.skills, Path::new("/r/workspace/agents/alpha/skills"));
- assert_eq!(layout.transcripts, Path::new("/r/workspace/session_raw"));
+ assert_eq!(
+ layout.transcripts,
+ Path::new("/r/workspace/agents/alpha/session_raw")
+ );
assert_eq!(layout.action_dir, Path::new("/r/a"));
}
diff --git a/crates/openhuman-embed/tests/runtime_agents.rs b/crates/openhuman-embed/tests/runtime_agents.rs
index 1e81eb4080..7cb49093db 100644
--- a/crates/openhuman-embed/tests/runtime_agents.rs
+++ b/crates/openhuman-embed/tests/runtime_agents.rs
@@ -335,7 +335,10 @@ fn one_runtime_hosts_independently_configured_agents() {
// Layout: every agent has its own home, transcripts and action dir.
assert_eq!(alpha.home_dir(), workspace_dir.join("agents/alpha"));
- assert_eq!(alpha.transcripts_dir(), workspace_dir.join("session_raw"));
+ assert_eq!(
+ alpha.transcripts_dir(),
+ workspace_dir.join("agents/alpha/session_raw")
+ );
assert_eq!(alpha.action_dir(), root_dir.join("agents/alpha/action"));
assert!(alpha.action_dir().is_dir());
assert_eq!(beta.action_dir(), beta_action.path());
@@ -396,12 +399,20 @@ 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 a thread resumes its own history.
- let transcripts: Vec<String> = std::fs::read_dir(alpha.transcripts_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
+ // 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()
+ };
+ assert!(
+ !workspace_dir.join("session_raw").exists()
+ || listing(&workspace_dir.join("session_raw")).is_empty(),
+ "no agent writes to the shared transcript directory"
+ );
// Asserted against names the writer itself produced, not a shape
// of our own. A turn's `session_id` is the raw session key the
// runtime minted; TinyAgents derives the transcript stem from it
@@ -409,7 +420,9 @@ fn one_runtime_hosts_independently_configured_agents() {
// component carrying a disambiguating digest). The previous
// `_alpha.jsonl` expectation predates that encoding — hosts used
// to mint `{unix_ts}_{agent}` stems — so it can no longer match.
- for (agent_id, session_id) in [("alpha", &a1.session_id), ("beta", &b0.session_id)] {
+ 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 transcript = transcripts
.iter()
.find(|f| f.starts_with(&format!("{session_id}-")))