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(tinyagents): extract stop-hook halt summary into a helper
Steven Enamakelb0799b627aae
diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rsindex d3a635826f..e1de3dbd23 100644--- a/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks.rs@@ -33,11 +33,23 @@ pub(super) fn install(model = %report.model,"[stop_hooks] hook voted to stop the turn — pausing run: {}", report.reason);- *halt_summary.lock().expect("stop-hook halt mutex poisoned") = Some(format!(- "Stopping after {} model call(s): {}",- report.iteration, report.reason- ));+ record_halt_summary(&halt_summary, report);}),));}}+++fn record_halt_summary(+ halt_summary: &super::HaltSummarySlot,+ report: &tinyagents_harness::middleware::library::StopReport,+) {+ *halt_summary.lock().expect("stop-hook halt mutex poisoned") = Some(format!(+ "Stopping after {} model call(s): {}",+ report.iteration, report.reason+ ));+}++#[cfg(test)]+#[path = "stop_hooks_tests.rs"]+mod tests;diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rsnew file mode 100644index 0000000000..f887d812b6--- /dev/null+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs@@ -0,0 +1,19 @@+use super::*;++#[test]+fn a_poisoned_halt_summary_does_not_abort_stop_reporting() {+ let slot: super::super::HaltSummarySlot = Arc::new(std::sync::Mutex::new(None));+ let poisoned = Arc::clone(&slot);+ assert!(std::thread::spawn(move || {+ let _guard = poisoned.lock().unwrap();+ panic!("synthetic prior writer failure");+ }).join().is_err());+ record_halt_summary(&slot, &tinyagents_harness::middleware::library::StopReport {+ hook: "budget".into(),+ reason: "limit reached".into(),+ iteration: 2,+ model: "test-model".into(),+ });+ assert_eq!(slot.lock().unwrap_or_else(std::sync::PoisonError::into_inner).as_deref(),+ Some("Stopping after 2 model call(s): limit reached"));+}