Skip to content

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

fix(session_host): surface typed failure causes in grounded close summaries

Steven Enamakel267407da198a
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
index ef2f7ac37f..ea8760489d 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close.rs
@@ -18,8 +18,9 @@ use tinyagents_harness::middleware::wrap_harness_instruction;
use crate::agent::{
session_host::turn_checkpoint::{
self, build_deterministic_checkpoint, build_deterministic_final_summary,
- close_verification_prompt, final_answer_instruction, harness_instruction_needles,
- render_tool_results, results_from_tool_outcomes,
+ build_deterministic_final_summary_with_cause, close_verification_prompt,
+ final_answer_instruction, harness_instruction_needles, render_tool_results,
+ results_from_tool_outcomes,
},
tinyagents::{SupplementalTrace, TinyagentsTurnOutcome, TurnModelSource},
};
@@ -234,12 +235,16 @@ pub(super) struct GroundedClose {
/// additional provider calls once its recovery budget is exhausted.
fn classified_halt_close(outcome: &TinyagentsTurnOutcome) -> Option<GroundedClose> {
let reason = outcome.breaker_halt.as_deref()?;
- if !reason.starts_with("Stopping after ") {
+ if outcome.failure_cause.is_none() && !reason.starts_with("Stopping after ") {
return None;
}
let records = results_from_tool_outcomes(&outcome.tool_outcomes);
Some(GroundedClose {
- output: build_deterministic_final_summary(&records, Some(reason)),
+ output: build_deterministic_final_summary_with_cause(
+ &records,
+ Some(reason),
+ outcome.failure_cause.as_ref(),
+ ),
usage: RepairUsage::default(),
})
}
@@ -398,7 +403,11 @@ pub(super) async fn close_if_needed(
if needs_cap_close {
build_deterministic_checkpoint(&records, outcome.model_calls)
} else {
- build_deterministic_final_summary(&records, stop_reason)
+ build_deterministic_final_summary_with_cause(
+ &records,
+ stop_reason,
+ outcome.failure_cause.as_ref(),
+ )
}
};
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
index c040d55864..6727ee40ef 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
@@ -166,7 +166,9 @@ fn unrecognized_typed_class_does_not_fall_back_to_english_halt_phrases() {
let close = classified_halt_close(&outcome).expect("typed halt");
assert!(
- close.output.contains("my tool calls were not getting anywhere"),
+ close
+ .output
+ .contains("my tool calls were not getting anywhere"),
"unknown typed classes use generic copy instead of parsing halt prose: {}",
close.output
);
diff --git a/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs b/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
index 569c6fba24..afa8d5fe04 100644
--- a/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
@@ -523,11 +523,7 @@ pub(crate) fn build_deterministic_final_summary_with_cause(
return "I finished this turn but produced no result to report.".to_string();
}
if let Some(reason) = stop_reason {
- return super::stop_summary::render_stop_summary_with_cause(
- results,
- reason,
- failure_cause,
- );
+ return super::stop_summary::render_stop_summary_with_cause(results, reason, failure_cause);
}
let mut out = String::from(
"I finished this turn without writing up a result. Here is what each tool call returned:\n",