Skip to content

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

chore: files changed crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs,crate

Steven Enamakel61a43b5c4c5d
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 103e5e7e43..b2ea0f188f 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -430,7 +430,7 @@ impl Middleware<(), crate::agent::tinyagents::host::OpenHumanRunContext>
let repeated_failure = failed && self.stop.witness().record_failure(tool_name, &arg_fp);
if !failed {
- self.stop.witness().record_success();
+ self.stop.record_success();
// Only a successful observation against this operation and scope
// demonstrates that its blocker changed. Unrelated successes do not.
for class in [
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/stop_latch.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/stop_latch.rs
index bf3947a0d2..2e5323e9b8 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/stop_latch.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/stop_latch.rs
@@ -56,23 +56,39 @@ impl StopLatch {
/// Stop the run, recording `summary` as its stop note unless another
/// breaker already stopped it. The pause is sent either way; it is
- /// idempotent.
- pub(super) fn halt(&self, summary: String) {
- if let Ok(mut slot) = self.slot.lock() {
- match slot.as_deref() {
- Some(existing) => tracing::debug!(
- existing = %crate::util::truncate_with_ellipsis(existing, 80),
- "[tinyagents::mw] run already stopped by an earlier breaker; keeping its stop note"
- ),
+ /// idempotent. Returns whether `summary` became the stop note.
+ pub(super) fn halt(&self, summary: String) -> bool {
+ let latched = match self.slot.lock() {
+ Ok(mut slot) => match slot.as_deref() {
+ Some(existing) => {
+ tracing::debug!(
+ existing = %crate::util::truncate_with_ellipsis(existing, 80),
+ "[tinyagents::mw] run already stopped by an earlier breaker; keeping its stop note"
+ );
+ false
+ }
None => {
*slot = Some(summary.clone());
if let Ok(mut own) = self.own.lock() {
*own = Some(summary);
}
+ true
}
- }
- }
+ },
+ Err(_) => false,
+ };
self.handle.send(SteeringCommand::Pause);
+ latched
+ }
+
+ /// A call ran and succeeded. The run made progress, so neither the
+ /// refusals before it nor a refusal after it can explain a stop latched
+ /// before it as a repeat loop.
+ pub(super) fn record_success(&self) {
+ self.witness.record_success();
+ if let Ok(mut candidate) = self.candidate.lock() {
+ *candidate = None;
+ }
}
/// Stop the run for an exhausted classified-failure budget.
@@ -91,17 +107,23 @@ impl StopLatch {
error_line: impl FnOnce() -> String,
) {
if !(repeated && is_correctable_class(class)) {
- return self.halt(summary);
+ self.halt(summary);
+ return;
}
let error_line = error_line();
match self.witness.refusals() {
+ // Only the stop that owns the note may be relabelled later: a
+ // second stop in the batch must not lend it its tool and error.
0 => {
- if let Ok(mut candidate) = self.candidate.lock() {
- *candidate = Some((tool.to_owned(), error_line));
+ if self.halt(summary) {
+ if let Ok(mut candidate) = self.candidate.lock() {
+ *candidate = Some((tool.to_owned(), error_line));
+ }
}
- self.halt(summary);
}
- refusals => self.halt(repeat_loop_halt_summary(tool, refusals, &error_line)),
+ refusals => {
+ self.halt(repeat_loop_halt_summary(tool, refusals, &error_line));
+ }
}
}