Skip to content

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

refactor(flows): consume portable run diagnostics

Steven Enamakelf4e2a273e4cc
diff --git a/crates/openhuman-core/src/flows/builder_tools/dry_run_diagnostics.rs b/crates/openhuman-core/src/flows/builder_tools/dry_run_diagnostics.rs
index c14a6ab237..18c49dea35 100644
--- a/crates/openhuman-core/src/flows/builder_tools/dry_run_diagnostics.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/dry_run_diagnostics.rs
@@ -111,27 +111,7 @@ pub(super) fn tool_call_arg_null_entries(
/// node simply has no predecessors, or none of them is a condition) — the
/// warning is still emitted, just without a named culprit node.
pub(super) fn find_upstream_condition(graph: &WorkflowGraph, node_id: &str) -> Option<String> {
- let mut visited: std::collections::HashSet<&str> = std::collections::HashSet::new();
- let mut queue: std::collections::VecDeque<&str> = graph
- .edges
- .iter()
- .filter(|edge| edge.to_node == node_id)
- .map(|edge| edge.from_node.as_str())
- .collect();
- while let Some(current) = queue.pop_front() {
- if !visited.insert(current) {
- continue;
- }
- if let Some(node) = graph.nodes.iter().find(|n| n.id == current) {
- if node.kind == tinyflows::model::NodeKind::Condition {
- return Some(node.id.clone());
- }
- }
- for edge in graph.edges.iter().filter(|edge| edge.to_node == current) {
- queue.push_back(edge.from_node.as_str());
- }
- }
- None
+ tinyflows::diagnostics::nearest_upstream_condition(graph, node_id)
}
/// Best-effort extraction of the human-readable error message the engine
@@ -143,19 +123,7 @@ pub(super) fn find_upstream_condition(graph: &WorkflowGraph, node_id: &str) -> O
/// itself (whose `diagnostics` stays empty for an error step — see
/// [`DryRunWorkflowTool::execute`]'s `node_errors` collection).
pub(super) fn tool_call_error_message(output: &Value, node_id: &str) -> Option<String> {
- output
- .get("nodes")?
- .get(node_id)?
- .get("items")?
- .as_array()?
- .iter()
- .find_map(|item| {
- item.get("json")?
- .get("error")?
- .get("message")?
- .as_str()
- .map(str::to_string)
- })
+ tinyflows::diagnostics::node_error_message(output, node_id)
}
/// The engine's own step-capturing observer, re-exported under the name
diff --git a/crates/openhuman-core/src/flows/ops/run_rows.rs b/crates/openhuman-core/src/flows/ops/run_rows.rs
index 8e1ad48fd4..55598c28cd 100644
--- a/crates/openhuman-core/src/flows/ops/run_rows.rs
+++ b/crates/openhuman-core/src/flows/ops/run_rows.rs
@@ -216,21 +216,7 @@ pub(super) fn finish_flow_run_row(
/// observer didn't emit an `on_step_finish` for (notably the trigger node),
/// and as the whole-run source when the observer saw nothing at all.
fn reconstruct_steps(output: &Value) -> Vec<FlowRunStep> {
- let Some(nodes) = output.get("nodes").and_then(Value::as_object) else {
- return Vec::new();
- };
- nodes
- .iter()
- .map(|(node_id, slot)| FlowRunStep {
- node_id: node_id.clone(),
- output: slot.get("items").cloned().unwrap_or(Value::Null),
- port: slot.get("port").and_then(Value::as_str).map(str::to_string),
- // Reconstructed post-hoc: no live status/timing (see FlowRunStep).
- status: None,
- duration_ms: None,
- diagnostics: Vec::new(),
- })
- .collect()
+ tinyflows_catalog::run_summary::reconstruct_steps(output)
}
/// Reads back whatever steps the live [`FlowRunObserver`] has already persisted
@@ -255,7 +241,6 @@ pub(super) fn current_persisted_steps(config: &Config, run_id: &str) -> Vec<Flow
/// (e.g. a run that paused immediately at a gate before any node finished),
/// falls back wholesale to the reconstruction.
pub(super) fn settle_steps(config: &Config, run_id: &str, output: &Value) -> Vec<FlowRunStep> {
- let reconstructed = reconstruct_steps(output);
let persisted = current_persisted_steps(config, run_id);
if persisted.is_empty() {
tracing::debug!(
@@ -264,21 +249,14 @@ pub(super) fn settle_steps(config: &Config, run_id: &str, output: &Value) -> Vec
reconstructed = reconstructed.len(),
"[flows] settle_steps: no live-observed steps — using post-hoc reconstruction"
);
- return reconstructed;
- }
- let mut merged = persisted;
- let mut filled = 0usize;
- for step in reconstructed {
- if !merged.iter().any(|s| s.node_id == step.node_id) {
- merged.push(step);
- filled += 1;
- }
+ return reconstruct_steps(output);
}
+ let merged = tinyflows_catalog::run_summary::settle_steps(persisted, output);
tracing::debug!(
target: "flows",
run_id,
step_count = merged.len(),
- filled_from_reconstruction = filled,
+ filled_from_reconstruction = merged.len(),
"[flows] settle_steps: merged live-observed steps with post-hoc reconstruction"
);
merged
@@ -336,14 +314,6 @@ pub(super) fn finalize_terminal_status(
settled: &[FlowRunStep],
pending_approvals: &[String],
) -> (&'static str, Option<String>) {
- if !pending_approvals.is_empty() {
- return ("pending_approval", None);
- }
- let status = degrade_completed_status(settled);
- let error = if status == "failed" {
- failed_step_error_summary(settled)
- } else {
- None
- };
- (status, error)
+ let summary = tinyflows_catalog::run_summary::terminal_status(settled, pending_approvals);
+ (summary.status, summary.error)
}
diff --git a/vendor/tinyflows b/vendor/tinyflows
index 8a01f0ee44..73c19c75f0 160000
--- a/vendor/tinyflows
+++ b/vendor/tinyflows
@@ -1 +1 @@
-Subproject commit 8a01f0ee4435f2713f4d1cb92d1ac4dfadbb7394
+Subproject commit 73c19c75f0aa292d939107200885720f6c42c663