The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(storage): merge replayed transcript into existing session
Steven Enamakel91f0dbe8d247
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.rsindex 6152fbb9a9..3515b38920 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@@ -65,10 +65,12 @@ fn a_legacy_workspace_is_adopted_once_and_the_next_process_resumes_in_place() {.collect();let legacy_bytes;let after_first;+ let canonical_stem;{let next = model(vec![ModelResponse::assistant("unused")], scenario.native);let mut host = build_host(root.path(), next, scenario.native, &thread);let stem = host.session_id().expect("bound session id");+ canonical_stem = stem.clone();let import = place_fixture(root.path(), scenario, &stem, "");assert_eq!(import, (2, 2, 0), "legacy fixture import counts");legacy_bytes = legacy_files@@ -94,6 +96,24 @@ fn a_legacy_workspace_is_adopted_once_and_the_next_process_resumes_in_place() {.any(|stem| !legacy_stems.contains(&stem.as_str())),"adopted transcript written");+ let adopted = after_first+ .get(&canonical_stem)+ .expect("legacy roots are adopted into the session's canonical stem");+ assert_eq!(+ adopted["messages"].as_array().unwrap().len(),+ 5,+ "both timestamped roots are preserved in the adopted conversation"+ );+ let adopted_json = serde_json::to_string(adopted).unwrap();+ for message in [+ "legacy system prompt",+ "legacy question 1",+ "legacy answer 1",+ "legacy question 2",+ "legacy answer 2",+ ] {+ assert!(adopted_json.contains(message), "adopted transcript lost {message}");+ }// A fresh process over the same workspace resumes without adopting again.let next = model(vec![ModelResponse::assistant("unused")], scenario.native);diff --git a/crates/openhuman-core/src/storage/import/sessions.rs b/crates/openhuman-core/src/storage/import/sessions.rsindex b4f4dbaf08..004f26858b 100644--- a/crates/openhuman-core/src/storage/import/sessions.rs+++ b/crates/openhuman-core/src/storage/import/sessions.rs@@ -495,8 +495,9 @@ fn replay_transcript(meta: &TranscriptMeta,tools: Option<&serde_json::Value>,records: Vec<DisplayRecord>,+ existing: Vec<TranscriptMessage>,) -> Result<usize> {- let mut logical = Vec::<TranscriptMessage>::new();+ let mut logical = existing;let mut group = Vec::<DisplayMessage>::new();let mut replayed = 0usize;let flush = |logical: &mut Vec<TranscriptMessage>,@@ -734,10 +735,11 @@ pub(crate) fn import_transcript_groups(let history = stores.transcripts.open_stem(&destination_stem, meta.clone())?;- if history.read_session()?.is_some() {- continue;- }- replay_transcript(history.as_ref(), &meta, tools.as_ref(), records)+ let existing = history+ .read_session()?+ .map(|session| session.messages)+ .unwrap_or_default();+ replay_transcript(history.as_ref(), &meta, tools.as_ref(), records, existing).with_context(|| format!("[sessions] replay transcript {}", path.display()))?;written += 1;}