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
refactor(session_host): use shared orphaned tool head repair
Steven Enamakelca3a758e26ab
diff --git a/crates/openhuman-core/src/agent/session_host/codec.rs b/crates/openhuman-core/src/agent/session_host/codec.rsindex e0b494695d..7d532326ae 100644--- a/crates/openhuman-core/src/agent/session_host/codec.rs+++ b/crates/openhuman-core/src/agent/session_host/codec.rs@@ -20,7 +20,7 @@ pub struct OpenHumanTranscriptCodec;impl TranscriptCodec<OpenHumanRunContext> for OpenHumanTranscriptCodec {fn decode_history(&self, transcript: &SessionTranscript) -> Result<Vec<Message>, RuntimeError> {- let rows = replayable_host_rows(&transcript.messages);+ let rows = tinyagents_session::transcript::repair_orphaned_tool_head(&transcript.messages);tinyagents_runtime::transcript::native_transcript_to_messages(&rows)?;Ok(message_convert::history_to_messages(&rows))}@@ -34,7 +34,7 @@ impl TranscriptCodec<OpenHumanRunContext> for OpenHumanTranscriptCodec {) -> Result<Vec<TranscriptMessage>, RuntimeError> {// Match against the same adopted view used by decode_history; dropped// legacy head results must not shift retained rows' metadata.- let prior = replayable_host_rows(prior);+ let prior = tinyagents_session::transcript::repair_orphaned_tool_head(prior);// TinyAgents owns the portable positional reconciliation. Keep the// host's adopted prior view so legacy rows that cannot be replayed do// not shift retained native metadata.@@ -301,33 +301,6 @@ fn attach_text_dialect_rounds(}}-/// Apply OpenHuman's historical orphan-head adoption to the replay view only.-fn replayable_host_rows(rows: &[TranscriptMessage]) -> std::borrow::Cow<'_, [TranscriptMessage]> {- // Old unpaired trims could persist tool results immediately after the- // frozen system prefix (#6721). Later orphan results still fail native- // validation. Merely resuming never rewrites the durable source.- let prefix = rows.iter().take_while(|row| row.role == "system").count();- let orphan_count = rows[prefix..]- .iter()- .take_while(|row| row.role == "tool")- .count();- if orphan_count == 0 {- std::borrow::Cow::Borrowed(rows)- } else {- tracing::warn!(- orphan_count,- "[session_host::codec] repaired legacy orphaned tool head"- );- std::borrow::Cow::Owned(- rows[..prefix]- .iter()- .chain(&rows[prefix + orphan_count..])- .cloned()- .collect(),- )- }-}-#[cfg(test)]#[path = "codec_adoption_tests.rs"]mod adoption_tests;