The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
refactor(session_host): delegate stop summary rendering to harness
Steven Enamakelc11d006e28f8
diff --git a/crates/openhuman-core/src/agent/session_host/mod.rs b/crates/openhuman-core/src/agent/session_host/mod.rsindex 13a6925c88..17b985bc32 100644--- a/crates/openhuman-core/src/agent/session_host/mod.rs+++ b/crates/openhuman-core/src/agent/session_host/mod.rs@@ -37,6 +37,7 @@ mod builder;mod builder_config;mod codec;mod driver;+mod product_copy;// Tool surface for live voice sessions (`voice::live`).#[cfg(feature = "voice")]mod live_tools;diff --git a/crates/openhuman-core/src/agent/session_host/product_copy.rs b/crates/openhuman-core/src/agent/session_host/product_copy.rsnew file mode 100644index 0000000000..e30ab6f5cb--- /dev/null+++ b/crates/openhuman-core/src/agent/session_host/product_copy.rs@@ -0,0 +1,19 @@+//! OpenHuman's user-facing copy for generic TinyAgents session operations.+//!+//! Rendering, classification and validation live in TinyAgents. This module+//! supplies the product wording at those seams.++/// OpenHuman copy for bounded summaries of a turn stopped by a breaker.+pub(crate) const OPENHUMAN_STOP_COPY: tinyagents_harness::turn_stop::StopCopy =+ tinyagents_harness::turn_stop::StopCopy {+ opening_template: "I stopped this turn early because {reason}.\n",+ what_happened_heading: "\n**What happened**\n",+ success_template: "- `{name}` succeeded{count}",+ failure_template: "- `{name}` failed{count}{error}",+ hidden_calls_template: "- …and {count} more tool call(s)",+ proceed_prompt: "\nTell me how you'd like to proceed, or ask me to try again.",+ };++/// OpenHuman's prompt and fallback wording for generic TinyAgents close paths.+pub(crate) const OPENHUMAN_CLOSE_COPY: tinyagents_harness::close::CloseCopy =+ tinyagents_harness::close::ENGLISH_CLOSE_COPY;diff --git a/crates/openhuman-core/src/agent/session_host/stop_summary.rs b/crates/openhuman-core/src/agent/session_host/stop_summary.rsindex 0baadea0f3..d399c93b34 100644--- a/crates/openhuman-core/src/agent/session_host/stop_summary.rs+++ b/crates/openhuman-core/src/agent/session_host/stop_summary.rs@@ -16,17 +16,12 @@//! locale table can replace [`StopReasonKind::copy`] without touching the//! classification.-use std::fmt::Write as _;-use super::turn_checkpoint::CheckpointToolResult;use tinyagents_harness::turn_stop::TurnStop;/// Longest error line shown for one tool, in characters.const ERROR_LINE_CHARS: usize = 120;-/// Most result lines listed; the rest are counted.-const MAX_LISTED: usize = 8;-/// Maps an unclassified breaker stop to the product's stable stop category.fn stop_fallback_class(note: &str) -> &'static str {StopReasonKind::from_stop_note(note).key()@@ -244,22 +239,6 @@ pub(crate) fn short_error_line(content: &str) -> String {format!("{}…", cut.trim_end())}-/// One collapsed line: a tool, whether it succeeded, the error line for a-/// failure, and how many results it stands for.-struct Group {- name: String,- success: bool,- error: String,- count: usize,-}--fn times(count: usize) -> String {- match count {- 1 => String::new(),- n => format!(" {n} times"),- }-}-/// The user-facing reply for a turn the breaker stopped with `stop_note`.pub(crate) fn render_stop_summary(results: &[CheckpointToolResult], stop_note: &str) -> String {let kind = StopReasonKind::from_stop_note(stop_note);@@ -268,51 +247,14 @@ pub(crate) fn render_stop_summary(results: &[CheckpointToolResult], stop_note: &results = results.len(),"[turn_checkpoint] rendering deterministic stop summary");- let mut groups: Vec<Group> = Vec::new();- for result in results {- let error = if result.success {- String::new()- } else {- short_error_line(&result.content)- };- match groups- .iter_mut()- .find(|g| g.name == result.name && g.success == result.success && g.error == error)- {- Some(group) => group.count += 1,- None => groups.push(Group {- name: result.name.clone(),- success: result.success,- error,- count: 1,- }),- }- }-- let mut out = format!("I stopped this turn early because {}.\n", kind.copy());- if !groups.is_empty() {- out.push_str("\n**What happened**\n");- // Show the most recent groups (the immediate blocker is last), in- // chronological order.- let shown_from = groups.len().saturating_sub(MAX_LISTED);- for group in groups.iter().skip(shown_from) {- let name = crate::util::truncate_with_ellipsis(&group.name, 60);- let count = times(group.count);- let _ = if group.success {- writeln!(out, "- `{name}` succeeded{count}")- } else if group.error.is_empty() {- writeln!(out, "- `{name}` failed{count}")- } else {- writeln!(out, "- `{name}` failed{count}: {}", group.error)- };- }- let hidden: usize = groups.iter().take(shown_from).map(|g| g.count).sum();- if hidden > 0 {- let _ = writeln!(out, "- …and {hidden} more tool call(s)");- }- }- out.push_str("\nTell me how you'd like to proceed, or ask me to try again.");- out+ let groups = tinyagents_harness::turn_stop::group_stop_results(results, |content| {+ short_error_line(content)+ });+ tinyagents_harness::turn_stop::render_stop_summary_with_copy(+ kind.copy(),+ &groups,+ &super::product_copy::OPENHUMAN_STOP_COPY,+ )}#[cfg(test)]diff --git a/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rs b/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rsindex 874b40ca9f..8c5d96ada0 100644--- a/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rs+++ b/crates/openhuman-core/src/agent/session_host/stop_summary_tests.rs@@ -208,7 +208,8 @@ fn a_policy_refusal_class_halt_names_the_security_settings() {/// most recent ones so the failure that stopped the turn stays visible.#[test]fn a_capped_summary_keeps_the_most_recent_groups() {- let mut results: Vec<_> = (0..MAX_LISTED + 2)+ // The user-facing summary shows the newest eight groups.+ let mut results: Vec<_> = (0..10).map(|i| result(&format!("early_tool_{i}"), true, "ok")).collect();results.push(result("final_blocker", false, "boom happened"));