Skip to content

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

feat(agent): carry typed stop cause through failure classification

Steven Enamakelfa3e17c4ae03
diff --git a/crates/openhuman-core/src/agent/session_host/stop_summary.rs b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
index 5069536d40..0baadea0f3 100644
--- a/crates/openhuman-core/src/agent/session_host/stop_summary.rs
+++ b/crates/openhuman-core/src/agent/session_host/stop_summary.rs
@@ -46,11 +46,40 @@ pub(crate) fn classify_stop(
TurnStop::classify(breaker_halt, wind_down, hit_cap, stop_fallback_class)
}
+/// Classifies a completed turn with the failure classifier's typed cause when
+/// the harness carried one through the run. The human-readable stop note stays
+/// available for display, but never recovers the class or operation.
+pub(crate) fn classify_stop_with_cause(
+ breaker_halt: Option<&str>,
+ failure_cause: Option<tinyagents_harness::no_progress::ClassifiedStopCause>,
+ wind_down: bool,
+ hit_cap: bool,
+) -> Option<TurnStop> {
+ TurnStop::classify_with_cause(
+ breaker_halt,
+ failure_cause,
+ wind_down,
+ hit_cap,
+ stop_fallback_class,
+ )
+}
+
/// Projects an incomplete result reason through the product's stop categories.
pub(crate) fn stop_from_incomplete(reason: &str) -> TurnStop {
TurnStop::from_incomplete_reason(reason, stop_fallback_class)
}
+/// Projects an incomplete result with its typed breaker cause, when available.
+pub(crate) fn stop_from_incomplete_with_cause(
+ reason: &str,
+ failure_cause: Option<tinyagents_harness::no_progress::ClassifiedStopCause>,
+) -> TurnStop {
+ if let Some(cause) = failure_cause {
+ return TurnStop::from_classified_cause(cause);
+ }
+ stop_from_incomplete(reason)
+}
+
/// Why the breaker stopped the turn, in terms a user can act on.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum StopReasonKind {
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 1127195687..e522e024cf 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure.rs
@@ -280,7 +280,14 @@ impl FailureScopePolicy<OpenHumanRunContext> for HostFailurePolicy {
if let Some(kind) = terminal_inference_failure_kind(heuristic) {
return FailureAssessment::Halt {
summary: terminal_inference_halt_summary(kind, &call.name, &failure_text),
- cause: None,
+ cause: Some(tinyagents_harness::no_progress::ClassifiedStopCause {
+ class: match kind {
+ crate::inference::failure_copy::TerminalInferenceFailure::BudgetExhausted => "out_of_credits",
+ crate::inference::failure_copy::TerminalInferenceFailure::ProviderConfig => "provider_config",
+ }.to_owned(),
+ operation: call.name.clone(),
+ summary: terminal_inference_halt_summary(kind, &call.name, &failure_text),
+ }),
};
}
}