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/progress_tracing/collector/events.rs,crates/ope

Steven Enamakel17267e246c81
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs
index ea5c0c1f51..6eeb67f7bc 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/events.rs
@@ -330,6 +330,7 @@ impl SpanCollector {
iterations,
output_chars,
output,
+ stop,
..
} => {
let Some(span_index) = self.retire_subagent(task_id, now_unix_ms, SpanStatus::Ok)
@@ -355,7 +356,20 @@ impl SpanCollector {
json_usize(*output_chars),
);
extra.insert("subagent.elapsed_ms".to_string(), json_u64(*elapsed_ms));
- self.close_span(state.span_index, start + elapsed_ms, SpanStatus::Ok, extra);
+ // A child the harness stopped early (breaker / iteration cap)
+ // is handed back incomplete: WARNING, not a clean Ok.
+ let status = match stop {
+ Some(stop) => {
+ Self::insert_stop_attrs(stop, &mut extra);
+ log::debug!(
+ "[agent-tracing] subagent stopped early task_id={task_id} {}",
+ stop.status_message()
+ );
+ SpanStatus::Unset
+ }
+ None => SpanStatus::Ok,
+ };
+ self.close_span(state.span_index, start + elapsed_ms, status, extra);
}
AgentProgress::SubagentFailed { task_id, error, .. } => {
@@ -468,13 +482,19 @@ impl SpanCollector {
}
}
- AgentProgress::TurnCompleted { iterations, .. } => {
+ AgentProgress::TurnCompleted { iterations, stop } => {
self.close_current_iteration(now_unix_ms);
if let Some(index) = self.turn_span_index {
- let mut extra = BTreeMap::new();
- extra.insert("agent.iterations".to_string(), json_u32(*iterations));
- extra.insert("turn.outcome".to_string(), json_str("completed"));
- self.close_span(index, now_unix_ms, SpanStatus::Ok, extra);
+ self.spans[index]
+ .attributes
+ .insert("agent.iterations".to_string(), json_u32(*iterations));
+ // A turn the harness stopped early still arrives here; it
+ // closes at WARNING instead of as a clean completion.
+ let outcome = match stop {
+ Some(stop) => super::state::TurnOutcome::Stopped { stop: stop.clone() },
+ None => super::state::TurnOutcome::Completed,
+ };
+ self.apply_turn_outcome(outcome, now_unix_ms);
}
}
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
index 0ff88212ff..5e63787510 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/finish.rs
@@ -74,7 +74,10 @@ impl SpanCollector {
/// (Langfuse statusMessage). The raw failure text can quote user data,
/// so it is attached only with content capture on; otherwise a fixed,
/// content-free message is used;
- /// * cancelled → status left unset, `observation.level = WARNING`.
+ /// * cancelled → status left unset, `observation.level = WARNING`;
+ /// * stopped (breaker / wind-down / iteration cap) → status left unset,
+ /// `observation.level = WARNING` plus the content-free stop attributes
+ /// ([`Self::insert_stop_attrs`]).
pub(crate) fn apply_turn_outcome(&mut self, outcome: TurnOutcome, now_unix_ms: u64) {
let Some(index) = self.turn_span_index else {
return;
@@ -116,6 +119,15 @@ impl SpanCollector {
);
(SpanStatus::Unset, "cancelled")
}
+ TurnOutcome::Stopped { stop } => {
+ Self::insert_stop_attrs(stop, &mut extra);
+ log::debug!(
+ "[agent-tracing] turn stopped early trace_id={} {}",
+ self.ctx.session_id,
+ stop.status_message()
+ );
+ (SpanStatus::Unset, "stopped")
+ }
};
if status == SpanStatus::Error {
extra.insert("error".to_string(), serde_json::Value::Bool(true));
@@ -128,6 +140,30 @@ impl SpanCollector {
self.close_span(index, now_unix_ms, status, extra);
}
+ /// Mark a span (turn or subagent) as stopped early: `WARNING` level, the
+ /// content-free `stopped: …` summary as its status message, and the
+ /// `turn.stop_*` attributes. The summary is also written as
+ /// `error.message`, which is what the OTLP converter exports as the
+ /// Langfuse statusMessage; it is safe ungated because it holds only the
+ /// stop kind, a failure class and a tool name.
+ pub(super) fn insert_stop_attrs(
+ stop: &crate::agent::turn_stop::TurnStop,
+ extra: &mut BTreeMap<String, serde_json::Value>,
+ ) {
+ let message = stop.status_message();
+ extra.insert(LEVEL_ATTR.to_string(), json_str("WARNING"));
+ extra.insert("observation.status_message".to_string(), json_str(&message));
+ extra.insert("error.message".to_string(), json_str(&message));
+ extra.insert("turn.outcome".to_string(), json_str("stopped"));
+ extra.insert("turn.stop_kind".to_string(), json_str(stop.kind.as_str()));
+ if let Some(class) = &stop.failure_class {
+ extra.insert("turn.stop_class".to_string(), json_str(class));
+ }
+ if let Some(operation) = &stop.operation {
+ extra.insert("turn.stop_operation".to_string(), json_str(operation));
+ }
+ }
+
/// Move a completed/failed subagent to `finished_subagents`, closing its
/// open iteration with `status`. Its still-open tool spans stay open so a
/// late completion can close them precisely. Returns the subagent span's
diff --git a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
index 570c969038..1d06c3a10e 100644
--- a/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
+++ b/crates/openhuman-core/src/agent/progress_tracing/collector/state.rs
@@ -106,6 +106,11 @@ pub enum TurnOutcome {
Cancelled { reason: Option<String> },
/// The stream closed before the turn reported an outcome.
Incomplete,
+ /// The harness stopped the turn early (failure breaker, deadline
+ /// wind-down, iteration cap) and it reached the completion path anyway.
+ Stopped {
+ stop: crate::agent::turn_stop::TurnStop,
+ },
}
/// Pure state machine that folds an [`crate::agent::progress::AgentProgress`]