Skip to content

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

refactor(session_host): invert final summary delegation

Steven Enamakel931aa0625e67
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 a5da843079..f71c2f1a5a 100644
--- a/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
+++ b/crates/openhuman-core/src/agent/session_host/turn_checkpoint.rs
@@ -509,7 +509,22 @@ pub(crate) fn build_deterministic_final_summary(
results: &[CheckpointToolResult],
stop_reason: Option<&str>,
) -> String {
- build_deterministic_final_summary_with_cause(results, stop_reason, None)
+ if results.is_empty() && stop_reason.is_none() {
+ 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(results, reason);
+ }
+ let mut out = String::from(
+ "I finished this turn without writing up a result. Here is what each tool call returned:\n",
+ );
+ if results.is_empty() {
+ out.push_str("\n- (no tool calls completed)\n");
+ } else {
+ out.push_str(&render_tool_results(results, CHECKPOINT_TOTAL_CHARS));
+ }
+ out.push_str("\nTell me how you'd like to proceed.");
+ out
}
/// Build a stopped-turn summary using its typed breaker cause when available.
@@ -519,24 +534,12 @@ pub(crate) fn build_deterministic_final_summary_with_cause(
stop_reason: Option<&str>,
failure_cause: Option<&tinyagents_harness::no_progress::ClassifiedStopCause>,
) -> String {
- if results.is_empty() && stop_reason.is_none() && failure_cause.is_none() {
- return "I finished this turn but produced no result to report.".to_string();
- }
- if stop_reason.is_some() || failure_cause.is_some() {
+ if let Some(cause) = failure_cause {
return super::stop_summary::render_stop_summary_with_cause(
results,
stop_reason.unwrap_or_default(),
- failure_cause,
+ Some(cause),
);
}
- let mut out = String::from(
- "I finished this turn without writing up a result. Here is what each tool call returned:\n",
- );
- if results.is_empty() {
- out.push_str("\n- (no tool calls completed)\n");
- } else {
- out.push_str(&render_tool_results(results, CHECKPOINT_TOTAL_CHARS));
- }
- out.push_str("\nTell me how you'd like to proceed.");
- out
+ build_deterministic_final_summary(results, stop_reason)
}