Skip to content

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

test(agent): align session tests with canonical transcript storage

Steven Enamakel46bf3edd32ed
diff --git a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs
index d74ec241b6..e01a7d0270 100644
--- a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_explicit_definition_tests.rs
@@ -30,7 +30,7 @@ async fn from_config_with_definition_stamps_the_definition_on_the_session() {
let config = test_config(&tmp);
let def = explicit_definition("embedded-alpha");
- let agent = Agent::from_config_with_definition(&config, &def, None, None)
+ let agent = Agent::from_config_with_definition(&config, &def)
.expect("build from an explicit definition");
assert_eq!(agent.agent_definition_id, "embedded-alpha");
@@ -61,7 +61,7 @@ async fn resolved_definition_prefers_the_sessions_own_over_a_same_id_registry_en
"the registry's orchestrator is not read-only, so a leak is observable"
);
- let agent = Agent::from_config_with_definition(&config, &def, None, None)
+ let agent = Agent::from_config_with_definition(&config, &def)
.expect("build from an explicit definition");
assert_eq!(
diff --git a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_memory_write_instruction_tests.rs b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_memory_write_instruction_tests.rs
index d5fdfaa51a..4846044e48 100644
--- a/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_memory_write_instruction_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/session/builder/builder_tests_memory_write_instruction_tests.rs
@@ -19,15 +19,9 @@ async fn memory_write_instruction_is_present_with_learning_disabled() {
"the default install has learning off; the write rule must not depend on it"
);
let orchestrator = builtin_def("orchestrator");
- let agent = Agent::build_session_agent_inner(
- &config,
- "orchestrator",
- Some(&orchestrator),
- None,
- false,
- None,
- )
- .expect("build session");
+ let agent =
+ Agent::build_session_agent_inner(&config, "orchestrator", Some(&orchestrator), false)
+ .expect("build session");
let prompt = agent
.build_system_prompt(LearnedContextData::default())
@@ -46,9 +40,8 @@ async fn memory_write_instruction_names_only_the_write_tool_a_scoped_agent_holds
let tmp = tempfile::TempDir::new().unwrap();
let config = test_config(&tmp);
let archivist = builtin_def("archivist");
- let agent =
- Agent::build_session_agent_inner(&config, "archivist", Some(&archivist), None, false, None)
- .expect("build archivist session");
+ let agent = Agent::build_session_agent_inner(&config, "archivist", Some(&archivist), false)
+ .expect("build archivist session");
let prompt = agent
.build_system_prompt(LearnedContextData::default())
diff --git a/crates/openhuman-core/src/agent/harness/session/session_thread_resume_scoped_tests.rs b/crates/openhuman-core/src/agent/harness/session/session_thread_resume_scoped_tests.rs
index aad9c3d94f..21a61c4528 100644
--- a/crates/openhuman-core/src/agent/harness/session/session_thread_resume_scoped_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/session/session_thread_resume_scoped_tests.rs
@@ -77,7 +77,6 @@ fn seed_resume_from_thread_transcript_scoped_does_not_leak_across_agents() {
let mut agent_b = build_minimal_agent_with_definition_name(Some("agent_b"));
agent_b.workspace_dir = wsp.clone();
- agent_b.session_raw_subdir = "session_raw".to_string();
assert!(
agent_b.seed_resume_from_thread_transcript_scoped(thread_id, Some("agent_b")),
diff --git a/crates/openhuman-core/src/agent/harness/session/session_thread_resume_tests.rs b/crates/openhuman-core/src/agent/harness/session/session_thread_resume_tests.rs
index 13630677d7..9385e39b75 100644
--- a/crates/openhuman-core/src/agent/harness/session/session_thread_resume_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/session/session_thread_resume_tests.rs
@@ -216,14 +216,9 @@ fn seed_resume_replays_compaction_to_reduced_context() {
);
}
-/// #5351 regression guard: resume must pick the NEWEST transcript across profile
-/// dirs, never the one in the agent's own dir. After the Reasoning profile is
-/// healed back to the shared `session_raw/`, an OLDER transcript there must not
-/// shadow the NEWER turns the profile wrote into its (pre-heal) scoped
-/// `session_raw-1/` — otherwise the switch drops the most recent context and the
-/// seeded history diverges from what the transcript view shows.
+/// Resume must pick the newest matching canonical transcript for a thread.
#[test]
-fn seed_resume_from_thread_transcript_picks_newest_across_profile_dirs() {
+fn seed_resume_from_thread_transcript_picks_newest_canonical_transcript() {
use super::super::transcript::{self, TranscriptMeta};
use crate::agent::messages::ChatMessage;
@@ -262,24 +257,22 @@ fn seed_resume_from_thread_transcript_picks_newest_across_profile_dirs() {
transcript::write_transcript(&old_path, &older, &meta("2026-01-01T00:00:00Z"), None)
.expect("write older");
- // NEWER transcript in a sibling scoped dir (written pre-heal, higher stem).
+ // NEWER transcript in the same canonical store.
let newer = vec![
ChatMessage::system("system prompt"),
ChatMessage::user("finalize plan"),
ChatMessage::assistant("FINAL: Minimax is the image generator"),
];
let new_path = wsp
- .join("session_raw-1")
+ .join("session_raw")
.join("1700009999_orchestrator.jsonl");
std::fs::create_dir_all(new_path.parent().unwrap()).unwrap();
transcript::write_transcript(&new_path, &newer, &meta("2026-02-02T00:00:00Z"), None)
.expect("write newer");
- // Agent runs in the shared dir (healed). Own-dir-first would wrongly pick the
- // older draft; newest-across-dirs must pick the finalized plan.
+ // The newest transcript must win over an older matching root transcript.
let mut agent = build_minimal_agent_with_definition_name(Some("orchestrator"));
agent.workspace_dir = wsp.clone();
- agent.session_raw_subdir = "session_raw".to_string();
assert!(agent.seed_resume_from_thread_transcript(thread_id));
let cached = agent
@@ -288,11 +281,11 @@ fn seed_resume_from_thread_transcript_picks_newest_across_profile_dirs() {
.expect("cached transcript populated");
assert!(
cached.iter().any(|m| m.content.contains("FINAL")),
- "resume must load the NEWEST transcript across profile dirs, not the older own-dir copy"
+ "resume must load the newest canonical transcript, not the older copy"
);
assert!(
!cached.iter().any(|m| m.content.contains("early draft")),
- "the older own-dir transcript must not shadow the newer sibling"
+ "the older transcript must not shadow the newer canonical transcript"
);
}
diff --git a/crates/openhuman-core/src/agent/harness/session/transcript_history_tests.rs b/crates/openhuman-core/src/agent/harness/session/transcript_history_tests.rs
index 9aeddc7d82..ea0992c637 100644
--- a/crates/openhuman-core/src/agent/harness/session/transcript_history_tests.rs
+++ b/crates/openhuman-core/src/agent/harness/session/transcript_history_tests.rs
@@ -394,7 +394,7 @@ fn transcript_fingerprint(t: &SessionTranscript) -> String {
}
fn locator(dir: &TempDir) -> FileTranscriptLocator {
- FileTranscriptLocator::new(dir.path(), "session_raw")
+ FileTranscriptLocator::new(dir.path())
}
/// A tool round persisted the way the turn path persists it: the assistant