Skip to content

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

fix(flows): correct dry run diagnostics for draft id tests

Steven Enamakel8a4ad1ece6db
diff --git a/crates/openhuman-core/src/flows/builder_tools.rs b/crates/openhuman-core/src/flows/builder_tools.rs
index 384e77a3d6..69c74017e6 100644
--- a/crates/openhuman-core/src/flows/builder_tools.rs
+++ b/crates/openhuman-core/src/flows/builder_tools.rs
@@ -70,7 +70,6 @@ mod draft_edit;
mod draft_revise;
mod draft_validate;
mod dry_run;
-mod dry_run_diagnostics;
mod flow_reads;
mod kind_reads;
mod persistence;
diff --git a/crates/openhuman-core/src/flows/builder_tools/dry_run.rs b/crates/openhuman-core/src/flows/builder_tools/dry_run.rs
index 52cc2b1dc3..ce3e5711b9 100644
--- a/crates/openhuman-core/src/flows/builder_tools/dry_run.rs
+++ b/crates/openhuman-core/src/flows/builder_tools/dry_run.rs
@@ -11,9 +11,8 @@ use crate::flows::ops;
use crate::flows::ops::validate_and_migrate_graph;
use tinytools::{PermissionLevel, Tool, ToolResult};
-use super::dry_run_diagnostics::{
- find_upstream_condition, tool_call_arg_null_entries, tool_call_error_message, CapturingObserver,
-};
+use tinyflows::authoring_report::{self, AuthoringReport};
+use tinyflows::observability::CapturingObserver;
/// Wall-clock bound on a single `dry_run_workflow` mock execution. A malformed
/// or pathological draft graph must never hang the agent tool-loop; the mock
@@ -282,29 +281,6 @@ impl Tool for DryRunWorkflowTool {
// below is scoped to just these (see the struct doc: a null in an
// `agent`'s prompt is not execution-breaking the way a null tool arg
// is, so only `tool_call` diagnostics fail the dry run).
- let tool_call_node_ids: std::collections::HashSet<&str> = graph
- .nodes
- .iter()
- .filter(|node| node.kind == tinyflows::model::NodeKind::ToolCall)
- .map(|node| node.id.as_str())
- .collect();
-
- // Which node ids are `agent` nodes — scoped narrowly to the ONE
- // execution-breaking agent diagnostic: a null-resolved `prompt`
- // itself (see the struct doc's "agent prompt nulls" section). Every
- // OTHER agent-config subfield (e.g. a null inside `tools` args) stays
- // non-fatal here, same as before.
- let agent_node_ids: std::collections::HashSet<&str> = graph
- .nodes
- .iter()
- .filter(|node| node.kind == tinyflows::model::NodeKind::Agent)
- .map(|node| node.id.as_str())
- .collect();
-
- // Capture every node's execution diagnostics (null-resolved
- // `=`-expressions the engine itself traced — see
- // `tinyflows::expr::resolve_traced`) as the sandbox run executes, so
- // they can be inspected once the run settles.
let observer = Arc::new(CapturingObserver::default());
let observer_dyn: Arc<dyn tinyflows::observability::RunObserver> = observer.clone();
let run = tinyflows::engine::run_with_observer(&compiled, input, &caps, &observer_dyn);
@@ -326,13 +302,8 @@ impl Tool for DryRunWorkflowTool {
// than letting the generic "required arg missing/null" text
// (which sent the transcript agent re-wiring a correct binding
// three times) stand alone. WS6.
- let unverifiable_bindings: Vec<Value> =
- tool_call_arg_null_entries(&observer.steps(), &graph, &tool_call_node_ids)
- .into_iter()
- .filter(|entry| {
- entry.get("unverifiable").and_then(Value::as_bool) == Some(true)
- })
- .collect();
+ let unverifiable_bindings =
+ authoring_report::unverifiable_bindings(&graph, &observer.steps());
if !unverifiable_bindings.is_empty() {
tracing::debug!(
target: "flows",
@@ -379,157 +350,16 @@ impl Tool for DryRunWorkflowTool {
// upstream Composio `tool_call`'s output is flagged `unverifiable`
// (the echo mock can't produce real tool output fields) rather than
// reported as a plain wiring mistake — see [`build_null_resolution_entry`].
- let null_resolutions: Vec<Value> =
- tool_call_arg_null_entries(&observer.steps(), &graph, &tool_call_node_ids);
-
- // Collect every null-resolved `agent`-node `prompt` — execution-
- // breaking in the same way a null `tool_call` arg is: `prompt` is the
- // node's ONLY input channel to the completion, so a `null` there
- // means the agent runs with an EMPTY prompt (the exact root-cause bug
- // `input_context` — and the static gate in
- // `ops::validate_binding_resolvability` — exist to prevent). Scoped
- // to the `location == "prompt"` diagnostic specifically: other
- // agent-config subfields (e.g. a null buried in `tools` args) stay
- // non-fatal here, same as before this check existed.
- let agent_prompt_nulls: Vec<Value> = observer
- .steps()
- .iter()
- .filter(|step| agent_node_ids.contains(step.node_id.as_str()))
- .flat_map(|step| {
- step.diagnostics
- .iter()
- .filter(|&diag| diag.location == "prompt")
- .map(|diag| {
- json!({
- "node_id": step.node_id,
- "location": diag.location,
- "expression": diag.expression,
- "suggestion": "Feed upstream data via input_context:\"=item\" and \
- make the prompt a plain instruction.",
- })
- })
- })
- .collect();
-
- // Collect every null-resolved `agent`-node `input_context` — mirrors
- // `agent_prompt_nulls` exactly (see the struct doc's "Agent-
- // `input_context` null check" section): `input_context` has been the
- // agent's primary upstream-data channel since #4590, so a null
- // resolution here is just as execution-breaking as a null `prompt` —
- // the agent runs with no upstream data at all.
- let agent_input_context_nulls: Vec<Value> = observer
- .steps()
- .iter()
- .filter(|step| agent_node_ids.contains(step.node_id.as_str()))
- .flat_map(|step| {
- step.diagnostics
- .iter()
- .filter(|&diag| diag.location == "input_context")
- .map(|diag| {
- json!({
- "node_id": step.node_id,
- "location": diag.location,
- "expression": diag.expression,
- "suggestion": "Wire input_context from a real upstream field, e.g. \
- \"=nodes.<node_id>.item.json.<field>\" (or \"=item\" off the \
- trigger), not an expression that resolves to null.",
- })
- })
- })
- .collect();
-
- // Collect every `tool_call` node whose EXECUTOR errored (e.g. the
- // Composio required-arg preflight rejecting a missing/null arg) —
- // regardless of that node's `on_error` policy. A `"continue"`/`"route"`
- // policy converts the failure into a routed error ITEM and the run
- // still completes successfully (`Ok(outcome)`), so the naive
- // `null_resolutions` check above misses it entirely: the failing
- // node's `ExecutionStep` carries an EMPTY `diagnostics` (the engine
- // never got far enough to trace an `=`-expression — see
- // `tinyflows::engine`'s error-item path) even though the node
- // genuinely failed. Only `"stop"` (the default) fails the whole run —
- // and that's already caught above via `Ok(Err(e))` before this point,
- // so every `StepStatus::Error` step reachable here is exactly the
- // continue/route case. The error text itself isn't on the step (the
- // engine only attaches it to the routed error item), so it's read
- // back out of `outcome.output`.
- let node_errors: Vec<Value> = observer
- .steps()
- .iter()
- .filter(|step| {
- tool_call_node_ids.contains(step.node_id.as_str())
- && matches!(step.status, tinyflows::observability::StepStatus::Error)
- })
- .map(|step| {
- let error =
- tool_call_error_message(&outcome.output, &step.node_id).unwrap_or_else(|| {
- format!(
- "tool_call node '{}' failed during the sandbox run — its `on_error` \
- policy turned the failure into routed/continued data instead of \
- failing the whole dry run, but the underlying error still means the \
- node is broken.",
- step.node_id
- )
- });
- json!({ "node_id": step.node_id, "error": error })
- })
- .collect();
-
- // Routing-divergence blind spot (B15): an `agent`/`tool_call` node that
- // did NOT execute during the sandbox run at all — because an upstream
- // `condition` routed the mock trigger payload onto its OTHER branch —
- // is invisible to every check above (`null_resolutions` etc. only
- // inspect steps that ran). But the mock input's *shape* need not match
- // a real trigger's shape (a webhook's real JSON vs. the dry run's `{}`
- // default, say), so a condition that took the `false` branch under mock
- // data may well take `true` at runtime with real data — or vice versa.
- // Either way, the dry run silently never exercised the very node whose
- // wiring most needed checking. This is a WARNING, not a hard reject
- // (an unexercised branch can be entirely intentional), surfaced
- // alongside the other diagnostics so the caller can double-check the
- // wiring by hand.
- let executed_steps = observer.steps();
- let executed_node_ids: std::collections::HashSet<&str> = executed_steps
- .iter()
- .map(|step| step.node_id.as_str())
- .collect();
- let routing_divergence_warnings: Vec<Value> = graph
- .nodes
- .iter()
- .filter(|node| {
- node.kind != tinyflows::model::NodeKind::Trigger
- && (agent_node_ids.contains(node.id.as_str())
- || tool_call_node_ids.contains(node.id.as_str()))
- && !executed_node_ids.contains(node.id.as_str())
- })
- .map(|node| {
- let condition_node_id = find_upstream_condition(&graph, &node.id);
- let message = match &condition_node_id {
- Some(cid) => format!(
- "Node '{}' did not execute in the dry run (condition '{}' routed to \
- the other branch under mock data); verify the wiring — at runtime \
- with real data it may route differently.",
- node.id, cid
- ),
- None => format!(
- "Node '{}' did not execute in the dry run (an upstream branch routed \
- the mock data away from it); verify the wiring — at runtime with real \
- data it may route differently.",
- node.id
- ),
- };
- json!({
- "node_id": node.id,
- "condition_node_id": condition_node_id,
- "message": message,
- })
- })
- .collect();
+ // The bucketing and advice wording live upstream (`tinyflows::authoring_report`);
+ // this tool keeps the mock capabilities, the timeout and the JSON envelope.
+ let AuthoringReport {
+ null_resolutions,
+ agent_prompt_nulls,
+ agent_input_context_nulls,
+ node_errors,
+ routing_divergence_warnings,
+ } = AuthoringReport::build(&graph, &observer.steps(), &outcome.output);
- // Quiet, informational only (never a prompt, never a gate): the
- // ApprovalGate permissions a real run of this graph will need, so the
- // builder agent can tell the user what the save+enable card will ask
- // for — the card itself fires at save+enable, NOT during dry runs.
let permissions_manifest =
crate::flows::ops::compute_approval_manifest(&self.config, &graph).await;
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
deleted file mode 100644
index 18c49dea35..0000000000
--- a/crates/openhuman-core/src/flows/builder_tools/dry_run_diagnostics.rs
+++ /dev/null
@@ -1,136 +0,0 @@
-//! Diagnostic helpers for `dry_run_workflow`: null-resolution entries, upstream
-//! condition lookup, routed tool-call error extraction, and the capturing observer.
-
-use serde_json::{json, Value};
-use tinyflows::model::WorkflowGraph;
-
-/// Builds one `null_resolutions` diagnostic entry for a `tool_call` node's
-/// null-resolved `args.*` config expression.
-///
-/// The common case reports `{ node_id, location, expression }` — a wiring
-/// mistake the agent should fix. But when the null-resolved expression binds to
-/// the output of an upstream Composio-or-native `tool_call` node
-/// ([`ops::mock_opaque_tool_call_upstream_ref`]), the entry is instead marked
-/// `unverifiable: true` and carries an honest `suggestion`: the echo sandbox
-/// can NEVER produce a tool's real output fields, so this particular null is
-/// expected here and does NOT prove the binding wrong (WS6 — the transcript
-/// audit where the agent re-wired an already-correct binding three times
-/// chasing this exact false negative). The suggestion adapts to the upstream
-/// kind: a Composio upstream points at `get_tool_contract` /
-/// `get_tool_output_sample` and the `.item.json.data.` nesting; a native `oh:`
-/// upstream points at the flat `.item.json.<field>` shape instead.
-fn build_null_resolution_entry(
- node_id: &str,
- diag: &tinyflows::expr::NullResolution,
- graph: &WorkflowGraph,
-) -> Value {
- if let Some(upstream) =
- tinyflows::preflight::mock_opaque_tool_call_upstream_ref(&diag.expression, graph, node_id)
- {
- let field = diag.location.strip_prefix("args.").unwrap_or("args");
- // The disambiguation advice differs by upstream kind: a native `oh:`
- // tool's output binds FLAT (`.item.json.<field>`) after
- // `native_tool_payload`'s unwrap — it has no `.data.` wrapper and no
- // Composio `get_tool_contract` — whereas a Composio action nests under
- // `.item.json.data.`. Emitting the Composio advice for a native
- // upstream would send the agent chasing a `.data.` path that will
- // never exist.
- let upstream_is_native = graph
- .nodes
- .iter()
- .find(|n| n.id == upstream)
- .and_then(|n| n.config.get("slug").and_then(Value::as_str))
- .is_some_and(|s| s.starts_with("oh:"));
- let suggestion = if upstream_is_native {
- format!(
- "required arg `{field}` binds to the output of native tool_call node \
- `{upstream}` — the SANDBOX only echoes tool calls and can never produce \
- their real output fields, so this binding is UNVERIFIABLE here (not \
- necessarily wrong). A native `oh:` tool's real output binds FLAT at \
- `=nodes.{upstream}.item.json.<field>` (no `.data.` wrapper). Confirm the \
- field name against that tool's own output shape. It is a real bug only if \
- the path doesn't match the tool's actual output."
- )
- } else {
- format!(
- "required arg `{field}` binds to the output of Composio tool_call node \
- `{upstream}` — the SANDBOX only echoes tool calls and can never produce \
- their real output fields, so this binding is UNVERIFIABLE here (not \
- necessarily wrong). Confirm the path against get_tool_contract {{ slug }}'s \
- output_fields / primary_array_path (remember Composio results nest under \
- `.item.json.data.`), or get_tool_output_sample {{ slug, args }} for the \
- real shape. It is a real bug only if the path doesn't match the action's \
- actual output."
- )
- };
- return json!({
- "node_id": node_id,
- "location": diag.location,
- "expression": diag.expression,
- "unverifiable": true,
- "upstream_tool_call": upstream,
- "suggestion": suggestion,
- });
- }
- json!({
- "node_id": node_id,
- "location": diag.location,
- "expression": diag.expression,
- })
-}
-
-/// Every null-resolved `args.*` config expression that landed on a `tool_call`
-/// node, as `null_resolutions` diagnostic entries (see
-/// [`build_null_resolution_entry`] for the shape, including the WS6
-/// `unverifiable` Composio-or-native-upstream variant). Shared by the settled-run path
-/// (which fails the dry run on these) and the errored-run path (which surfaces
-/// only the `unverifiable` ones so a stop-policy preflight abort explains
-/// itself honestly instead of via the generic required-arg text).
-pub(super) fn tool_call_arg_null_entries(
- steps: &[tinyflows::observability::ExecutionStep],
- graph: &WorkflowGraph,
- tool_call_node_ids: &std::collections::HashSet<&str>,
-) -> Vec<Value> {
- steps
- .iter()
- .filter(|step| tool_call_node_ids.contains(step.node_id.as_str()))
- .flat_map(|step| {
- step.diagnostics
- .iter()
- .filter(|&diag| diag.location == "args" || diag.location.starts_with("args."))
- .map(|diag| build_null_resolution_entry(&step.node_id, diag, graph))
- })
- .collect()
-}
-
-/// Walks a graph backward from `node_id`'s predecessors (any number of hops)
-/// to find the nearest ancestor that is a `condition` node — used to name the
-/// branch responsible for a routing-divergence warning (see
-/// [`DryRunWorkflowTool::execute`]'s routing-divergence check, just above).
-/// Returns `None` if no predecessor chain reaches a `condition` node (e.g. the
-/// 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> {
- tinyflows::diagnostics::nearest_upstream_condition(graph, node_id)
-}
-
-/// Best-effort extraction of the human-readable error message the engine
-/// recorded for a `tool_call` node whose `on_error` policy is `"continue"` or
-/// `"route"`. Such a node's failure is converted into an error ITEM on its
-/// output (`{ "error": { "message", "node" } }` — see `tinyflows::engine`'s
-/// `error_item`) rather than failing the whole run, so the message lives in
-/// the run's `output` state, not on the [`tinyflows::observability::ExecutionStep`]
-/// 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> {
- tinyflows::diagnostics::node_error_message(output, node_id)
-}
-
-/// The engine's own step-capturing observer, re-exported under the name
-/// [`DryRunWorkflowTool`]'s call sites already use.
-///
-/// It is upstream because what it captures is the engine's:
-/// `ExecutionStep::diagnostics` holds the `=`-expressions that resolved to null
-/// while a node's config was being assembled, which is the only place a graph's
-/// real wiring failure is visible. This host used to declare an identical copy.
-pub(crate) use tinyflows::observability::CapturingObserver;
diff --git a/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs b/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs
index 5026cbaa19..31fba06114 100644
--- a/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs
+++ b/crates/openhuman-core/src/flows/builder_tools_draft_id_tests.rs
@@ -233,7 +233,6 @@ fn module_doc_tool_table_matches_registered_tools() {
include_str!("builder_tools/draft_revise.rs"),
include_str!("builder_tools/draft_validate.rs"),
include_str!("builder_tools/dry_run.rs"),
- include_str!("builder_tools/dry_run_diagnostics.rs"),
include_str!("builder_tools/flow_reads.rs"),
include_str!("builder_tools/kind_reads.rs"),
include_str!("builder_tools/persistence.rs"),