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(agent): handle missing session messages during import
Steven Enamakel07656562fb0c
diff --git a/crates/openhuman-core/src/agent/messages.rs b/crates/openhuman-core/src/agent/messages.rsindex 0f1bcb3094..0f42f9cbad 100644--- a/crates/openhuman-core/src/agent/messages.rs+++ b/crates/openhuman-core/src/agent/messages.rs@@ -14,6 +14,12 @@//! [`history_wire`] keeps writing exactly that shape, so a binary of either//! generation reads what the other wrote, and reads any row shape (the//! vendor row is a superset whose extra fields default).+//!+//! The in-memory row is typed (tool calls, call ids and image parts are+//! fields, `content` is plain text), but these files stay the flat string+//! pairs they always were: a write rebuilds the established string form+//! (`legacy_content`: the native envelope for a tool round, `[IMAGE:<url>]`+//! markers for image parts) and a read lifts it back into the typed row.use serde::ser::SerializeSeq;use serde::{Deserialize, Deserializer, Serialize, Serializer};@@ -25,6 +31,23 @@ struct WireRow<'a> {content: &'a str,}+/// The flat `content` string a typed row is stored as. Image parts use the+/// host's own `[IMAGE:<url>]` marker (which both generations read), not the+/// private native-wire marker.+fn wire_content(row: &TranscriptMessage) -> String {+ if row.parts.is_some() {+ row.display_content()+ } else {+ row.legacy_content()+ }+}++/// A deserialized row with any string-encoded structure lifted into the typed+/// fields.+fn lifted(row: TranscriptMessage) -> TranscriptMessage {+ row.normalized()+}+fn serialize_rows<S: Serializer>(rows: &[TranscriptMessage],serializer: S,@@ -33,7 +56,7 @@ fn serialize_rows<S: Serializer>(for row in rows {seq.serialize_element(&WireRow {role: &row.role,- content: &row.content,+ content: &wire_content(row),})?;}seq.end()@@ -53,7 +76,10 @@ pub mod history_wire {pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D,) -> Result<Vec<TranscriptMessage>, D::Error> {- Vec::<TranscriptMessage>::deserialize(deserializer)+ Ok(Vec::<TranscriptMessage>::deserialize(deserializer)?+ .into_iter()+ .map(lifted)+ .collect())}/// The same contract for an `Option<Vec<TranscriptMessage>>` field.@@ -73,7 +99,8 @@ pub mod history_wire {pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D,) -> Result<Option<Vec<TranscriptMessage>>, D::Error> {- Option::<Vec<TranscriptMessage>>::deserialize(deserializer)+ Ok(Option::<Vec<TranscriptMessage>>::deserialize(deserializer)?+ .map(|rows| rows.into_iter().map(lifted).collect()))}}}diff --git a/crates/openhuman-core/src/agent/session_import/projector.rs b/crates/openhuman-core/src/agent/session_import/projector.rsindex a7351da50c..ef4ed1c23a 100644--- a/crates/openhuman-core/src/agent/session_import/projector.rs+++ b/crates/openhuman-core/src/agent/session_import/projector.rs@@ -98,12 +98,22 @@ fn journal_extra_metadata(message: &TranscriptMessage) -> Option<serde_json::Valextra}+/// The journal's established string form of a row: the native envelope for a+/// tool round, `[IMAGE:<url>]` markers for image parts, plain text otherwise.+fn journal_content(message: &TranscriptMessage) -> String {+ if message.parts.is_some() {+ message.display_content()+ } else {+ message.legacy_content()+ }+}+/// The `JournalProjector` OpenHuman passes to the importer.pub fn journal_message_from_transcript(message: TranscriptMessage) -> JournalMessage {JournalMessage {id: message.id.clone(),role: message.role.clone(),- content: message.content.clone(),+ content: journal_content(&message),extra_metadata: journal_extra_metadata(&message),}}