Skip to content

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

refactor(tinyagents): return classified stop cause from failure policy hooks

Steven Enamakel46ca71a87f4a
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
index 15c60be520..c4178739f1 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -394,8 +394,12 @@ impl FailureScopePolicy<OpenHumanRunContext> for HostFailurePolicy {
repeat_guard_marker(result).is_some()
}
- fn record_guard_refusal(&self, _ctx: &RunContext<OpenHumanRunContext>) {
+ fn record_guard_refusal(
+ &self,
+ _ctx: &RunContext<OpenHumanRunContext>,
+ ) -> Option<tinyagents_harness::no_progress::ClassifiedStopCause> {
self.stop.record_refusal();
+ self.stop.current_classified_cause()
}
fn record_progress(
@@ -403,12 +407,13 @@ impl FailureScopePolicy<OpenHumanRunContext> for HostFailurePolicy {
ctx: &RunContext<OpenHumanRunContext>,
_call: &TaToolCall,
_scope: &FailureScope,
- ) {
+ ) -> Option<tinyagents_harness::no_progress::ClassifiedStopCause> {
self.stop.record_success();
self.last_exit_report
.lock()
.unwrap_or_else(|p| p.into_inner())
.remove(&ctx.instance_id());
+ self.stop.current_classified_cause()
}
fn reset_no_progress_before_failure(
@@ -457,11 +462,12 @@ impl FailureScopePolicy<OpenHumanRunContext> for HostFailurePolicy {
call: &TaToolCall,
repeated: bool,
error: &str,
- ) {
+ ) -> Option<tinyagents_harness::no_progress::ClassifiedStopCause> {
self.stop
.record_classified_halt(summary.to_owned(), class, &call.name, repeated, || {
first_error_line(error)
});
+ self.stop.current_classified_cause()
}
fn finish_run(&self, ctx: &RunContext<OpenHumanRunContext>) {