Skip to content

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

test(agent): cover stopped runs as failed results and logged stops

Steven Enamakelaead81462c3e
diff --git a/crates/openhuman-core/src/agent/tools/run_workflow_tests.rs b/crates/openhuman-core/src/agent/tools/run_workflow_tests.rs
index 5117fb54a8..79ec154735 100644
--- a/crates/openhuman-core/src/agent/tools/run_workflow_tests.rs
+++ b/crates/openhuman-core/src/agent/tools/run_workflow_tests.rs
@@ -185,3 +185,32 @@ async fn each_agent_owns_its_workflow_await_guard() {
assert!(alpha_again.is_err(), "alpha still holds its own key");
drop(held);
}
+
+/// A run the harness stopped early (footer `STOPPED`) did not finish: the
+/// tool result must be a failure so the calling agent's failure policy and
+/// trace see it, while a `DONE` run stays a success.
+#[test]
+fn a_stopped_run_is_a_failed_tool_result() {
+ let path = std::path::Path::new("/tmp/run.log");
+ let stopped = outcome_to_result(
+ "run-1",
+ "wf",
+ path,
+ Some(crate::skills::run_log::RunOutcome {
+ status: "STOPPED".to_string(),
+ output: "I stopped this turn early because …".to_string(),
+ }),
+ );
+ assert!(stopped.is_error, "{}", stopped.output());
+ assert!(stopped.output().contains("STOPPED"));
+ let done = outcome_to_result(
+ "run-1",
+ "wf",
+ path,
+ Some(crate::skills::run_log::RunOutcome {
+ status: "DONE".to_string(),
+ output: "ok".to_string(),
+ }),
+ );
+ assert!(!done.is_error);
+}
diff --git a/crates/openhuman-core/src/skills/run_log_tests.rs b/crates/openhuman-core/src/skills/run_log_tests.rs
index ea6a74d58c..0168e9e497 100644
--- a/crates/openhuman-core/src/skills/run_log_tests.rs
+++ b/crates/openhuman-core/src/skills/run_log_tests.rs
@@ -268,3 +268,24 @@ fn noisy_events_are_skipped_steps_are_kept() {
assert!(line.contains("memory_search"));
assert!(line.contains("it 2"));
}
+
+/// A workflow run whose turn the harness stopped early (breaker, wind-down,
+/// iteration cap) must not be written up as `DONE`: the drain hands the stop
+/// back so the footer can say `STOPPED`, and the step log names it.
+#[tokio::test]
+async fn drain_to_log_returns_the_turns_stop() {
+ let dir = tempfile::tempdir().expect("tempdir");
+ let path = dir.path().join("run.log");
+ let (tx, rx) = tokio::sync::mpsc::channel(4);
+ tx.send(AgentProgress::TurnCompleted {
+ iterations: 5,
+ stop: Some(crate::agent::turn_stop::TurnStop::iteration_cap()),
+ })
+ .await
+ .unwrap();
+ drop(tx);
+ let stop = drain_to_log(rx, path.clone()).await;
+ assert_eq!(stop, Some(crate::agent::turn_stop::TurnStop::iteration_cap()));
+ let log = std::fs::read_to_string(&path).expect("log written");
+ assert!(log.contains("stopped: iteration_cap"), "{log}");
+}