Skip to content

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

fix(agent): handle missing message conversion for session host accessors

Steven Enamakel73d79dcccf73
diff --git a/crates/openhuman-core/src/agent/message_convert.rs b/crates/openhuman-core/src/agent/message_convert.rs
index f451e03f81..ede9ea0cd2 100644
--- a/crates/openhuman-core/src/agent/message_convert.rs
+++ b/crates/openhuman-core/src/agent/message_convert.rs
@@ -560,6 +560,32 @@ pub(crate) fn messages_to_conversation(messages: &[Message]) -> Vec<TranscriptEn
out
}
+/// Presentation projection of a runtime session's messages, as returned by
+/// `OpenHumanSessionHost::history`.
+///
+/// [`messages_to_conversation`] keeps native tool-call structure
+/// (`AssistantToolCalls`, coalesced `ToolResults`). A text dialect (xml,
+/// pformat, code) has no native tool messages: the session records each round's
+/// results as one `[Tool results]` user row, so that replay frame is read back
+/// into a `ToolResults` entry as well. Callers such as the flows builder
+/// (`extract_workflow_proposal`) and the trail-off backstop match the
+/// `ToolResults` variant, which stays unreachable if every message is flattened
+/// into `TranscriptEntry::Chat`.
+pub(crate) fn messages_to_history_projection(messages: &[Message]) -> Vec<TranscriptEntry> {
+ messages_to_conversation(messages)
+ .into_iter()
+ .map(|entry| match entry {
+ TranscriptEntry::Chat(message) if message.role == DialectRole::User => {
+ match tinytools_agent::dialect::parse_replayed_results(&message.content) {
+ Some(results) => TranscriptEntry::ToolResults(results),
+ None => TranscriptEntry::Chat(message),
+ }
+ }
+ other => other,
+ })
+ .collect()
+}
+
/// The suffix of `messages` produced *after* the most recent user turn — i.e.
/// the assistant/tool messages a single turn appended. Robust to front-trimming
/// middleware (which drops old messages but keeps the current user turn).
diff --git a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
index 96959402ca..ee17bf9cf2 100644
--- a/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
+++ b/crates/openhuman-core/src/agent/session_host/runtime/accessors.rs
@@ -8,7 +8,7 @@ use crate::tools::agent_policy::ToolPolicyEngine;
use std::collections::HashSet;
use std::sync::Arc;
use tinytools::{Tool, ToolSpec};
-use tinytools_agent::dialect::{parse_replayed_results, TranscriptEntry};
+use tinytools_agent::dialect::TranscriptEntry;
impl OpenHumanSessionHost {
// ─────────────────────────────────────────────────────────────────
@@ -251,33 +251,9 @@ impl OpenHumanSessionHost {
/// or mutable `TranscriptEntry` accumulator in the host would recreate
/// the session state now owned by `tinyagents_runtime::Session`.
pub fn history(&self) -> Vec<TranscriptEntry> {
- // `messages_to_conversation` keeps the tool-call structure
- // (`AssistantToolCalls`) and coalesces native tool messages into
- // `ToolResults` batches. A text dialect (xml, pformat, code) has no
- // native tool messages: the session records each round's results as one
- // `[Tool results]` user row, so that replay frame is read back into a
- // `ToolResults` entry too. Callers such as the flows builder
- // (`extract_workflow_proposal`) and the trail-off backstop match the
- // `ToolResults` variant, and flattening every message into
- // `TranscriptEntry::Chat` made it unreachable.
self.runtime_session
.as_ref()
- .map(|session| {
- crate::agent::message_convert::messages_to_conversation(session.history())
- .into_iter()
- .map(|entry| match entry {
- TranscriptEntry::Chat(message)
- if message.role == tinytools_agent::dialect::DialectRole::User =>
- {
- match parse_replayed_results(&message.content) {
- Some(results) => TranscriptEntry::ToolResults(results),
- None => TranscriptEntry::Chat(message),
- }
- }
- other => other,
- })
- .collect()
- })
+ .map(|session| crate::agent::message_convert::messages_to_history_projection(session.history()))
.unwrap_or_default()
}