Skip to content

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

fix(threads): preserve failed text-dialect tool status in transcript projection

Steven Enamakel96215289a910
diff --git a/crates/openhuman-core/src/threads/transcript_view/project.rs b/crates/openhuman-core/src/threads/transcript_view/project.rs
index 3564f177a2..48fd2036db 100644
--- a/crates/openhuman-core/src/threads/transcript_view/project.rs
+++ b/crates/openhuman-core/src/threads/transcript_view/project.rs
@@ -241,6 +241,13 @@ impl Projector {
log::debug!("{LOG_PREFIX} sanitize: dropped system line from projection");
}
"user" => {
+ // The strict dialect replay shape also starts with
+ // `[Tool results]`. Handle it first so its persisted failure
+ // IDs are applied rather than treating every block as success.
+ if let Some(results) = parse_replayed_results(&msg.message.content) {
+ self.text_tool_results(msg, results);
+ return;
+ }
if let Some(blocks) = prompt_tools::parse_tool_results(msg) {
// Tool plumbing, not something the user said.
for block in blocks {
@@ -254,12 +261,6 @@ impl Projector {
}
return;
}
- // A text dialect folds a round's results into one user turn; it
- // is tool output, never the user's words.
- if let Some(results) = parse_replayed_results(&msg.message.content) {
- self.text_tool_results(msg, results);
- return;
- }
// A legacy turn without request ids still restarts the step
// count at its prompt.
self.step = 0;
diff --git a/crates/openhuman-core/src/threads/transcript_view/transcript_view_tool_round_tests.rs b/crates/openhuman-core/src/threads/transcript_view/transcript_view_tool_round_tests.rs
index 1c2376f3bd..fd0e638481 100644
--- a/crates/openhuman-core/src/threads/transcript_view/transcript_view_tool_round_tests.rs
+++ b/crates/openhuman-core/src/threads/transcript_view/transcript_view_tool_round_tests.rs
@@ -135,6 +135,18 @@ fn text_dialect_tool_turn_projects_calls_on_their_issuing_row_as_settled() {
let rows = OpenHumanTranscriptCodec
.reconcile(&[], &[], &next, &options)
.unwrap();
+ let failed_result = rows
+ .iter()
+ .find(|row| row.role == "user" && row.content.starts_with("[Tool results]"))
+ .expect("text dialect result row");
+ assert_eq!(
+ failed_result
+ .extra_metadata
+ .as_ref()
+ .and_then(|meta| meta.get("openhuman_tool_failures")),
+ Some(&serde_json::json!(["call_file_read_1"])),
+ "codec must preserve failed tool IDs on the result row: {failed_result:?}"
+ );
let usage = OpenHumanTranscriptCodec.turn_usage(&options).unwrap();
let meta = transcript::TranscriptMeta {