Lesson 7 / 26
End Nodes and Workflow Outputs
Every path should finish with a defined result.
One contract for every path
An end node finishes a run and returns its output. Whatever path the run took (answered, rejected, escalated, blocked by a guardrail), the caller should get a predictable shape: for example a reply text plus a status field. Without this, the app embedding the workflow must guess what happened. Design the output contract first, make every branch end in it, and include enough detail (status, reason, IDs) for your app and logs.
An output contract for all paths
The same fields whichever branch ran.
{
"status": "answered" | "rejected" | "escalated" | "blocked",
"reply": "text shown to the user",
"reason": "short machine-readable reason, e.g. approval_rejected",
"ticket_id": "optional, when escalated"
}Test each end
Write one preview test per terminal path, including the blocked and rejected ones.
Quick check: Why should every branch return the same output shape?
- So the calling app can handle results predictably
- To make runs slower
- Because branches cannot differ
- To hide errors
Answer
So the calling app can handle results predictably — One contract, many paths.