Skip to content

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

test(tinyagents): cover repeat guard results staying out of failure ladder

Steven Enamakeld0c4b1c92daa
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs
index 7e27d861a9..5483d66390 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware_command_exit_failure_tests.rs
@@ -188,3 +188,25 @@ async fn a_faulted_module_tool_is_steered_away_once_then_halts() {
let summary = slot.lock().unwrap().clone().unwrap();
assert!(summary.contains("unavailable"), "{summary}");
}
+
+/// A result the repeat guard answered itself (blocked/halted without running
+/// the tool) is the guard's verdict, not the tool failing: it must stay out of
+/// the failure ladder even when its text would classify as a hard failure.
+#[tokio::test]
+async fn a_repeat_guard_result_never_feeds_the_failure_ladder() {
+ let handle = SteeringHandle::allow_all();
+ let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
+ let mw = RepeatedToolFailureMiddleware::new(handle.clone(), 3, slot.clone());
+ for round in 0..6 {
+ let mut result = failing_result("gmail_send", "401 Unauthorized");
+ result.metadata = Some(json!({ "tinyagents.repeat_guard": "blocked" }));
+ let id = format!("guard-{round}");
+ let mut call = TaToolCall::new(&id, "gmail_send", json!({ "to": "[email protected]" }));
+ mw.before_tool(&mut ctx(), &(), &mut call).await.unwrap();
+ mw.after_tool(&mut ctx(), &(), &invocation(&id, "gmail_send"), &mut result)
+ .await
+ .unwrap();
+ }
+ assert_eq!(drain_pause_count(&handle), 0);
+ assert!(slot.lock().unwrap().is_none());
+}