Skip to content

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

fix(accessors): reparse text-dialect tool results in session history

Steven Enamakel0f887252b1f0
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 65f8b79261..d92cfc0787 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::TranscriptEntry;
+use tinytools_agent::dialect::{parse_replayed_results, TranscriptEntry};
impl OpenHumanSessionHost {
// ─────────────────────────────────────────────────────────────────
@@ -252,15 +252,31 @@ impl OpenHumanSessionHost {
/// 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 tool messages into
- // `ToolResults` batches. Callers such as the flows builder
- // (`extract_workflow_proposal`), the trail-off backstop and
- // `count_iterations` match those variants, so flattening every message
- // into `TranscriptEntry::Chat` made them unreachable.
+ // (`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::Role::User =>
+ {
+ match parse_replayed_results(&message.content) {
+ Some(results) => TranscriptEntry::ToolResults(results),
+ None => TranscriptEntry::Chat(message),
+ }
+ }
+ other => other,
+ })
+ .collect()
})
.unwrap_or_default()
}
diff --git a/crates/openhuman-core/src/flows/ops/builder.rs b/crates/openhuman-core/src/flows/ops/builder.rs
index ad66f9618e..662ddcd375 100644
--- a/crates/openhuman-core/src/flows/ops/builder.rs
+++ b/crates/openhuman-core/src/flows/ops/builder.rs
@@ -299,7 +299,6 @@ pub(crate) async fn flows_build_with_extra_hidden_tools(
// staring at the original silent/status-only text.
let runtime_history = agent.history();
let proposal = extract_workflow_proposal(&runtime_history);
- for e in &runtime_history { eprintln!("DBG-HIST {}", format!("{e:?}").chars().take(1500).collect::<String>()); }
// A user-cancelled turn settles here, clean and separate from the
// error/trail-off paths below: `finalize_flow_stream` gets an `Ok(...)` (a