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
test(tinyagents): cover stop reporting through middleware
Steven Enamakeledeb1235770e
diff --git a/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs b/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rsindex f11d96cc02..9806f9a714 100644--- a/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs+++ b/crates/openhuman-core/src/agent/tinyagents/stop_hooks_tests.rs@@ -1,7 +1,27 @@use super::*;-#[test]-fn a_poisoned_halt_summary_does_not_abort_stop_reporting() {+struct StopImmediately;++#[async_trait::async_trait]+impl tinyagents_hooks::stop::StopHook for StopImmediately {+ fn name(&self) -> &str {+ "budget"+ }++ async fn check(+ &self,+ _state: &tinyagents_hooks::stop::TurnState<'_>,+ ) -> tinyagents_hooks::stop::StopDecision {+ tinyagents_hooks::stop::StopDecision::Stop {+ reason: "limit reached".into(),+ }+ }+}++#[tokio::test]+async fn a_poisoned_halt_summary_does_not_abort_stop_reporting() {+ use tinyagents_harness::middleware::Middleware as _;+let slot: tinyagents_harness::turn_outcome::HaltSummarySlot =Arc::new(std::sync::Mutex::new(None));let poisoned = Arc::clone(&slot);@@ -11,19 +31,24 @@ fn a_poisoned_halt_summary_does_not_abort_stop_reporting() {}).join().is_err());- record_halt_summary(- &slot,- &tinyagents_hooks::stop::StopReport {- hook: "budget".into(),- reason: "limit reached".into(),- iteration: 2,- model: "test-model".into(),- },- );++ let middleware = StopHookMiddleware::new("test-model", vec![Arc::new(StopImmediately)])+ .with_halt_summary(Arc::clone(&slot));+ let mut context = tinyagents_harness::context::RunContext::new(+ tinyagents_harness::context::RunConfig::new("stop-summary-test"),+ (),+ )+ .with_steering(tinyagents_harness::steering::SteeringHandle::allow_all());+ let mut response = tinyinference_llm::model::ModelResponse::assistant("done");+ middleware+ .after_model(&mut context, &(), &mut response)+ .await+ .unwrap();+assert_eq!(slot.lock().unwrap_or_else(std::sync::PoisonError::into_inner).as_deref(),- Some("Stopping after 2 model call(s): limit reached")+ Some("Stopping after 1 model call(s): limit reached"));}