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 breaker stop functionality

Steven Enamakeld38e9c8dbafb
diff --git a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs
index 727656d92e..26d7563cef 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/progress_tracing_stop_tests.rs
@@ -24,6 +24,16 @@ fn root(spans: &[TraceSpan]) -> &TraceSpan {
.expect("turn span")
}
+fn classified_breaker_stop() -> tinyagents_harness::turn_stop::TurnStop {
+ crate::agent::turn_projection::breaker_stop_with_cause(
+ tinyagents_harness::no_progress::ClassifiedStopCause {
+ class: "uncertain_side_effect".into(),
+ operation: "web_answer_tool".into(),
+ summary: BREAKER_NOTE.into(),
+ },
+ )
+}
+
fn exported_level(spans: &[TraceSpan], name: &str) -> Option<String> {
let payloads = otlp_requests(
spans,
@@ -57,7 +67,7 @@ fn a_breaker_stopped_turn_closes_at_warning_with_stop_attributes() {
(
AgentProgress::TurnCompleted {
iterations: 4,
- stop: Some(crate::agent::turn_projection::breaker_stop(BREAKER_NOTE)),
+ stop: Some(classified_breaker_stop()),
},
50,
),
@@ -169,7 +179,7 @@ fn a_stopped_subagent_span_closes_at_warning_with_stop_attributes() {
(
subagent_completed(
"t-stop",
- Some(crate::agent::turn_projection::breaker_stop(BREAKER_NOTE)),
+ Some(classified_breaker_stop()),
),
40,
),
diff --git a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
index 1b4c474420..9fe581d008 100644
--- a/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
+++ b/crates/openhuman-core/src/agent/session_host/driver/grounded_close_tests.rs
@@ -26,6 +26,11 @@ fn classified_halt_returns_partial_work_without_provider_usage() {
wrap_up_injected: false,
truncated: false,
breaker_halt: Some("Stopping after 1 attempt(s): failure class `permission` still blocks operation `search` on `catalog`. Resolve this blocker before retrying.".into()),
+ failure_cause: Some(tinyagents_harness::no_progress::ClassifiedStopCause {
+ class: "permission".into(),
+ operation: "search".into(),
+ summary: "permission blocks search".into(),
+ }),
tool_outcomes: vec![
ToolCallOutcome { call_id: "a".into(), name: "list".into(), arguments: serde_json::json!({}), success: true, content: "three items".into(), duration_ms: 1 },
ToolCallOutcome { call_id: "b".into(), name: "search".into(), arguments: serde_json::json!({}), success: false, content: "403 Forbidden".into(), duration_ms: 1 },
@@ -217,6 +222,7 @@ fn blank_outcome(truncated: bool) -> TinyagentsTurnOutcome {
hit_cap: false,
wrap_up_injected: false,
breaker_halt: None,
+ failure_cause: None,
truncated,
compaction: None,
tool_outcomes: Vec::new(),
diff --git a/crates/openhuman-core/src/agent/turn_projection.rs b/crates/openhuman-core/src/agent/turn_projection.rs
index 268853e2f1..ea4becea26 100644
--- a/crates/openhuman-core/src/agent/turn_projection.rs
+++ b/crates/openhuman-core/src/agent/turn_projection.rs
@@ -20,6 +20,13 @@ pub fn breaker_stop(note: &str) -> TurnStop {
TurnStop::breaker(note, stop_fallback_class)
}
+/// Project a classifier-owned stop cause without recovering facts from text.
+pub fn breaker_stop_with_cause(
+ cause: tinyagents_harness::no_progress::ClassifiedStopCause,
+) -> TurnStop {
+ TurnStop::from_classified_cause(cause)
+}
+
/// [`TurnStop::classify`] with the OpenHuman stop-reason fallback.
pub fn classify_stop(
breaker_halt: Option<&str>,
diff --git a/crates/openhuman-core/src/agent/turn_projection_tests.rs b/crates/openhuman-core/src/agent/turn_projection_tests.rs
index a89279b3c7..e2d16d38d7 100644
--- a/crates/openhuman-core/src/agent/turn_projection_tests.rs
+++ b/crates/openhuman-core/src/agent/turn_projection_tests.rs
@@ -5,9 +5,17 @@ const CLASSIFIED_NOTE: &str = "Stopping after 2 attempt(s): failure class \
`uncertain_side_effect` still blocks operation `web_answer_tool` on \
`https://example.com/private?q=secret`. Resolve this blocker before retrying.";
+fn classified_cause() -> tinyagents_harness::no_progress::ClassifiedStopCause {
+ tinyagents_harness::no_progress::ClassifiedStopCause {
+ class: "uncertain_side_effect".into(),
+ operation: "web_answer_tool".into(),
+ summary: "classified failure summary".into(),
+ }
+}
+
#[test]
fn a_classified_breaker_note_keeps_its_class_and_drops_its_scope() {
- let stop = breaker_stop(CLASSIFIED_NOTE);
+ let stop = breaker_stop_with_cause(classified_cause());
assert_eq!(stop.kind, TurnStopKind::Breaker);
assert_eq!(stop.failure_class.as_deref(), Some("uncertain_side_effect"));
assert_eq!(stop.operation.as_deref(), Some("web_answer_tool"));
@@ -43,8 +51,11 @@ fn an_incomplete_reason_maps_to_cap_or_breaker() {
stop_from_incomplete(SUBAGENT_ITERATION_CAP_REASON).kind,
TurnStopKind::IterationCap
);
+ let stop = stop_from_incomplete(CLASSIFIED_NOTE);
+ assert_eq!(stop.kind, TurnStopKind::Breaker);
+ assert_eq!(stop.operation, None, "legacy prose cannot inject typed metadata");
assert_eq!(
- stop_from_incomplete(CLASSIFIED_NOTE).operation.as_deref(),
+ breaker_stop_with_cause(classified_cause()).operation.as_deref(),
Some("web_answer_tool")
);
}