Skip to content

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

feat(subagent): expose classified stop cause in neutral outcomes

Steven Enamakelc4d413acc100
diff --git a/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs b/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs
index 472d5b99f9..31db51b00e 100644
--- a/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs
+++ b/crates/openhuman-core/src/agent/subagent_host/lifecycle_outcome.rs
@@ -5,11 +5,17 @@ use super::*;
/// The host's in-flight subagent runs of one agent context.
pub(super) type HostInFlightMap = AsyncMutex<HashMap<HostLifecycleKey, Arc<HostInFlight>>>;
+const CLASSIFIED_STOP_CAUSE_EXTENSION: &str = "openhuman.classified_stop_cause";
+
pub(super) fn host_outcome_to_neutral(
outcome: SubagentRunOutcome,
definition: &crate::agent::harness::host_definition::AgentDefinition,
options: &SubagentRunOptions,
) -> SubagentOutcome {
+ let failure_cause = match &outcome.status {
+ SubagentRunStatus::Incomplete { failure_cause, .. } => failure_cause.clone(),
+ _ => None,
+ };
let status = match outcome.status {
SubagentRunStatus::Completed => SubagentOutcomeKind::Completed,
SubagentRunStatus::AwaitingUser { question, .. } => {
@@ -40,12 +46,12 @@ pub(super) fn host_outcome_to_neutral(
},
})
}
- SubagentRunStatus::Incomplete { reason } => {
+ SubagentRunStatus::Incomplete { reason, .. } => {
SubagentOutcomeKind::Incomplete(SubagentIncomplete::new(reason))
}
SubagentRunStatus::Cancelled => SubagentOutcomeKind::Cancelled,
};
- SubagentOutcome {
+ let mut neutral = SubagentOutcome {
task_id: outcome.task_id,
output: outcome.output,
history: outcome
@@ -82,5 +88,14 @@ pub(super) fn host_outcome_to_neutral(
})
.collect(),
..SubagentOutcome::cancelled(String::new())
+ };
+ if let Some(cause) = failure_cause {
+ // Keep only bounded machine identifiers in neutral durable metadata;
+ // the human-readable summary may contain private tool or URL details.
+ neutral.extensions.insert(
+ CLASSIFIED_STOP_CAUSE_EXTENSION.into(),
+ serde_json::json!({"class": cause.class, "operation": cause.operation}),
+ );
}
+ neutral
}
diff --git a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure_tests.rs b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure_tests.rs
index f87865109d..f4808eb469 100644
--- a/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure_tests.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/middleware/repeated_failure_tests.rs
@@ -1,5 +1,40 @@
use super::*;
+#[tokio::test]
+async fn classified_stop_cause_survives_the_latch_cleanup_on_agent_finish() {
+ use tinyagents_harness::{context::RunConfig, middleware::AgentRun, steering::SteeringPolicy};
+
+ let slot = std::sync::Arc::new(std::sync::Mutex::new(None));
+ let handle = SteeringHandle::new(SteeringPolicy::new());
+ let middleware = RepeatedToolFailureMiddleware::new(handle, 3, slot);
+ middleware.stop.halt_classified(
+ "classified summary".into(),
+ "uncertain_side_effect",
+ "web_answer_tool",
+ false,
+ String::new,
+ );
+ let mut run = AgentRun::default();
+ let mut context = RunContext::new(
+ RunConfig::new("classified-stop"),
+ crate::agent::tinyagents::host::OpenHumanRunContext::new(),
+ );
+
+ middleware
+ .after_agent(&mut context, &(), &mut run)
+ .await
+ .expect("middleware cleanup succeeds");
+
+ assert_eq!(
+ run.failure_cause,
+ Some(tinyagents_harness::no_progress::ClassifiedStopCause {
+ class: "uncertain_side_effect".into(),
+ operation: "web_answer_tool".into(),
+ summary: "classified summary".into(),
+ })
+ );
+}
+
#[test]
fn identical_recoverable_halt_uses_openhuman_copy() {
let ladder = RecoverableFailureLadder::default();