Skip to content

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

feat(skills): add run log for workflow executions

Steven Enamakel32c1977c6665
diff --git a/crates/openhuman-core/src/agent/tools/run_workflow.rs b/crates/openhuman-core/src/agent/tools/run_workflow.rs
index abbccd3645..46072616e5 100644
--- a/crates/openhuman-core/src/agent/tools/run_workflow.rs
+++ b/crates/openhuman-core/src/agent/tools/run_workflow.rs
@@ -193,6 +193,27 @@ fn outcome_to_result(
outcome: Option<crate::skills::run_log::RunOutcome>,
) -> ToolResult {
match outcome {
+ // The harness stopped the run's turn early: it did not finish, so the
+ // caller's failure policy and trace must see a failure, not a result.
+ Some(o) if o.status == "STOPPED" => {
+ tracing::debug!(
+ run_id,
+ workflow_id,
+ "[run_workflow] run was stopped early; returning a failed tool result"
+ );
+ ToolResult::error(
+ json!({
+ "run_id": run_id,
+ "workflow_id": workflow_id,
+ "status": o.status,
+ "error": "The workflow run was stopped before it finished. Do not report it \
+ as done; relay the blocker below or try a different approach.",
+ "output": o.output,
+ "log": log_path.display().to_string(),
+ })
+ .to_string(),
+ )
+ }
Some(o) => ToolResult::success(
json!({
"run_id": run_id,
diff --git a/crates/openhuman-core/src/skills/run_log.rs b/crates/openhuman-core/src/skills/run_log.rs
index 59aeebbaa8..299014d7c0 100644
--- a/crates/openhuman-core/src/skills/run_log.rs
+++ b/crates/openhuman-core/src/skills/run_log.rs
@@ -221,6 +221,13 @@ pub fn format_event(ev: &AgentProgress) -> Option<String> {
" ⮑ subagent {agent_id} awaiting user: {}",
truncate(question, 200)
),
+ AgentProgress::TurnCompleted {
+ iterations,
+ stop: Some(stop),
+ } => format!(
+ "turn {} ({iterations} iterations)",
+ stop.status_message()
+ ),
AgentProgress::TurnCompleted { iterations, .. } => {
format!("turn completed ({iterations} iterations)")
}
@@ -249,12 +256,16 @@ pub async fn drain_to_log(
mut rx: Receiver<AgentProgress>,
path: PathBuf,
) -> Option<crate::agent::turn_stop::TurnStop> {
+ let mut stop = None;
while let Some(ev) = rx.recv().await {
if let Some(line) = format_event(&ev) {
let _ = append(&path, &line).await;
}
+ if let AgentProgress::TurnCompleted { stop: Some(s), .. } = &ev {
+ stop = Some(s.clone());
+ }
}
- None
+ stop
}
/// Detect the degenerate "model emitted the same paragraph many times in one
@@ -298,7 +309,7 @@ pub struct ScannedRun {
pub workflow_id: String,
/// Header `started:` timestamp (RFC3339); empty if header was malformed.
pub started: String,
- /// `"DONE"` / `"DEGENERATE"` / `"FAILED"` / `"RUNNING"` (running ⇔ no footer yet).
+ /// `"DONE"` / `"STOPPED"` / `"DEGENERATE"` / `"FAILED"` / `"RUNNING"` (running ⇔ no footer yet).
pub status: String,
/// Footer `duration: <ms> ms`, parsed; `None` while running.
pub duration_ms: Option<u64>,
diff --git a/crates/openhuman-core/src/skills/runtime/run_machinery.rs b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
index 3635063628..cea5d5acab 100644
--- a/crates/openhuman-core/src/skills/runtime/run_machinery.rs
+++ b/crates/openhuman-core/src/skills/runtime/run_machinery.rs
@@ -246,7 +246,7 @@ pub async fn spawn_workflow_run_background(
};
agent.set_on_progress(None);
drop(agent);
- let _ = bridge.await;
+ let stop = bridge.await.ok().flatten();
let ms = started.elapsed().as_millis() as u64;
run_log::unregister_run_cancel(&run_id);
@@ -257,6 +257,17 @@ pub async fn spawn_workflow_run_background(
.await;
tracing::info!(run_id = %run_id, "[workflows] workflow_run: cancelled");
}
+ Some(Ok(out)) if stop.is_some() => {
+ // The harness stopped the run's turn early (breaker,
+ // wind-down, iteration cap): it did not finish, so it is
+ // not `DONE`. `run_workflow` reports `STOPPED` as a failure.
+ let summary = stop.as_ref().map(|s| s.status_message()).unwrap_or_default();
+ let _ = run_log::write_footer(&log_path, "STOPPED", ms, &out).await;
+ tracing::warn!(
+ run_id = %run_id,
+ "[skills] workflow_run: turn stopped early, not marking DONE {summary}"
+ );
+ }
Some(Ok(out)) => {
if let Some((line, count)) = run_log::detect_repeated_line(&out, 30, 4) {
let preview = line.chars().take(160).collect::<String>();