Skip to content

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

refactor(agent): introduce classified stop cause to turn outcomes

Steven Enamakelc15b527f5f6e
diff --git a/crates/openhuman-core/src/agent/session_host/driver.rs b/crates/openhuman-core/src/agent/session_host/driver.rs
index e9f2f2778d..40040f1acc 100644
--- a/crates/openhuman-core/src/agent/session_host/driver.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver.rs
@@ -468,8 +468,9 @@ impl SessionDriver<OpenHumanRunContext> for OpenHumanSessionDriver {
observed.wrap_up_injected = outcome.wrap_up_injected;
// How the harness stopped the turn, if it did. The wind-down
// middleware marked the sidecar during the run.
- observed.stop = crate::agent::turn_projection::classify_stop(
+ observed.stop = crate::agent::turn_projection::classify_stop_with_cause(
outcome.breaker_halt.as_deref(),
+ outcome.failure_cause.clone(),
observed.wind_down,
outcome.hit_cap,
);
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs
index 2af5deec41..27b6e9a5b5 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_outcome.rs
@@ -65,6 +65,9 @@ pub(crate) struct TinyagentsTurnOutcome {
/// `text` already carries this same summary; the flag lets the status mapper
/// distinguish a breaker halt from a genuine final answer.
pub breaker_halt: Option<String>,
+ /// Typed classifier facts accompanying a no-progress halt. Kept separate
+ /// from the human-readable summary so projections never parse prose.
+ pub failure_cause: Option<tinyagents_harness::no_progress::ClassifiedStopCause>,
/// `true` when the run ended on a reply that ran out of output tokens
/// (`finish_reason = length`) with no visible text and no tool call — the
/// model spent its whole output budget reasoning, even after the harness's
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
index cb66dfa3ec..7e880d58e3 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_run_finalize.rs
@@ -163,8 +163,13 @@ pub(super) async fn finalize_turn_outcome(
// A run the harness stopped (breaker / cap) is traced as stopped, not as a
// clean completion. No deadline wind-down on this path: only the session
// turn carries one, and it records the stop through its sidecar.
- let stop =
- crate::agent::turn_projection::classify_stop(breaker_halt.as_deref(), false, hit_cap);
+ let failure_cause = run.failure_cause.clone();
+ let stop = crate::agent::turn_projection::classify_stop_with_cause(
+ breaker_halt.as_deref(),
+ failure_cause.clone(),
+ false,
+ hit_cap,
+ );
if let Some(stop) = stop.as_ref().filter(|_| turn_completed_sink.is_some()) {
tracing::debug!(
model,
@@ -292,6 +297,7 @@ pub(super) async fn finalize_turn_outcome(
hit_cap,
wrap_up_injected,
breaker_halt,
+ failure_cause,
truncated,
tool_outcomes,
compaction,
diff --git a/crates/openhuman-core/src/agent/turn_projection.rs b/crates/openhuman-core/src/agent/turn_projection.rs
index a51564948a..268853e2f1 100644
--- a/crates/openhuman-core/src/agent/turn_projection.rs
+++ b/crates/openhuman-core/src/agent/turn_projection.rs
@@ -29,6 +29,23 @@ pub fn classify_stop(
TurnStop::classify(breaker_halt, wind_down, hit_cap, stop_fallback_class)
}
+/// Typed-aware variant for stops whose harness run carries a classified cause.
+/// The human-readable halt note remains presentation data and is never parsed.
+pub 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,
+ )
+}
+
/// [`TurnStop::from_incomplete_reason`] with the OpenHuman stop-reason fallback.
pub fn stop_from_incomplete(reason: &str) -> TurnStop {
TurnStop::from_incomplete_reason(reason, stop_fallback_class)