Skip to content

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

fix(tinyagents): capture failure cause before agent finishes

Steven Enamakela0836a2b23fd
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 cc77e72585..4b9f901422 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -532,6 +532,11 @@ impl Middleware<(), OpenHumanRunContext> for RepeatedToolFailureMiddleware {
state: &(),
run: &mut tinyagents_harness::middleware::AgentRun,
) -> TaResult<()> {
+ // The owner's `after_agent` finishes the run and clears the stop latch,
+ // so read the typed cause first or it is lost on a classified halt.
+ if run.failure_cause.is_none() {
+ run.failure_cause = self.policy.stop.current_classified_cause();
+ }
self.owner.after_agent(ctx, state, run).await
}