How to Build AI Workflows
Build workflows as sequences of outcomes with checkpoints and idempotent steps, not as long prompt chains that fail silently at step nine.
Direct Answer (Quick Summary)
You build AI workflows by defining the outcome, decomposing it into steps with checkable completion conditions, making each step idempotent, checkpointing state after every one, and writing the failure behaviour at design time rather than during an incident. The unit of design is the outcome. A workflow that cannot resume from its last successful step is a demo.
Key Takeaways
- Design from the outcome backwards. If you cannot state the completion condition in one sentence, the workflow is not specified yet.
- Every step needs a checkable completion condition — a field present, a row written, a file created — not "the model finished".
- Make steps idempotent so a retry after an unknown failure cannot double-charge, double-send or double-write.
- Checkpoint after each step so a failed run resumes from the last success instead of starting over.
- Write the failure behaviour at design time; adding it during an incident produces retries that repeat the original fault.
- Split across employees only when the handoff has a contract. A handoff with no defined input and output is where workflows actually break.
You build AI workflows by defining the outcome, decomposing it into steps that each have a checkable completion condition, making every step idempotent, checkpointing after each one, and writing down what happens when a step fails. The unit of design is the outcome, not the prompt. A workflow that cannot resume from its last successful step is a demo, no matter how well the individual steps work.
A workflow is a sequence of outcomes
The common approach is to write one long instruction and let the model figure out the steps. It works in a demo because the demo input is narrow, and it fails in production because real inputs vary along exactly the dimensions you did not enumerate.
The alternative is to define the outcome precisely, then make each step responsible for a smaller outcome with a completion condition anyone can verify without reading the model's reasoning. "Every disputed invoice is matched to a payment or flagged with a reason" has a completion condition. "Understand the billing situation" does not. Why outcomes matter more than prompts covers the reasoning; designing an AI employee workflow covers the step-by-step version.
The seven steps
- Name the outcome in one sentence, with a completion condition. If you cannot write the condition, stop here — this is where most failed workflows actually stall.
- Decompose into steps of three to seven tool calls. Longer steps are impossible to diagnose; shorter steps make the reasoning trivial and the overhead dominant.
- Give each step one job. If a step needs two verbs, it is two steps, and the failure of one should not take the other with it.
- Make each step idempotent. Re-running it must produce the same end state, not a second one. Reads are naturally idempotent; anything that writes, sends or charges is not, until you design it that way.
- Checkpoint after each step. The run must be resumable from the last success without repeating the ones before it.
- Define the failure path per step. Retry limit, whether a partial result is acceptable, who gets told, and what the human is asked to decide.
- Define the escalation trigger. The condition that moves the run to review instead of continuing. Write it before the first live run.
Steps 5 and 6 are the two most commonly skipped, and they are the difference between a workflow and a script that occasionally fails in a way nobody can reproduce. How AI employees handle multi-step work covers what happens inside a step once it starts.
Worked example: quote-to-close
Take a workflow that turns an inbound enquiry into a submitted quote. Outlier-heavy, multi-system, and exactly the shape that breaks naive prompt chains.
| Step | Action | Completion condition | Idempotency note |
|---|---|---|---|
| 1 | Parse the enquiry | Required fields present or a follow-up drafted | Read-only |
| 2 | Pull the customer's account and history | Account id resolved, history returned | Read-only |
| 3 | Price the work | Line items produced with a total | Regenerate in place, keyed on enquiry id |
| 4 | Draft the quote document | File exists at a known path | Overwrite same path |
| 5 | Submit for human review | Status is review with the document attached | Status transition, guarded by current state |
| 6 | Send and record | Send logged with a message id | Guarded by send log, never blind retry |
Two details carry the weight. Step 3 keys its output on the enquiry id, so a re-run overwrites rather than appends a second quote. Step 6 checks the send log before sending, because the failure mode there is not "the send failed" — it is "the send succeeded and the response was lost", and a blind retry emails the customer twice. That is the failure designing reliable AI workflows exists to prevent.
Where workflows break: the handoff
Most production failures are not inside a step. They are between employees. When one AI employee hands work to another, someone has to have decided what the input is and what a valid output looks like — and if they did not, the second employee receives prose and improvises, and the first one cannot tell whether the result is usable.
That is why building an AI employee hierarchy is a design task rather than an org chart exercise. A handoff needs: a defined input shape, a defined output shape, a validation step that rejects malformed results, and a defined owner when the handoff fails repeatedly. How AI employees coordinate across workflows covers the mechanics where several employees share a workflow.
Split across employees only when the handoff has that contract. One employee with a longer workflow is almost always better than three employees with an undefined interface — the coordination cost is real and it is paid on every run.
Failure mode: the step that cannot fail cleanly
The most expensive workflow defect is a step that partially completes. It sends three of four emails, writes two of five rows, or charges a card and then times out before recording the charge. Retrying it makes things worse, and not retrying means the run sits forever.
Design the step to be atomic from the system's perspective, even if it is not atomic from the model's. That usually means: write intent first, act, then write confirmation — so a timeout leaves a record you can reconcile rather than a mystery. Where that is impossible, make the partial state explicit in the checkpoint and give the human a resume affordance rather than a retry button. Recovering from failed AI executions covers the operational version of that.
The three numbers that tell you whether it works
A workflow that runs and produces nothing useful is worse than no workflow, because it looks like progress. Three numbers separate the two, and all three are readable from the run history without extra instrumentation.
| Number | What it tells you | The warning sign |
|---|---|---|
| Completion rate | Share of runs reaching the defined completion condition | Falling as input volume grows |
| Human-touch rate | Share of runs a person had to finish by hand | High but stable, meaning the design is wrong rather than the model |
| Cost per completed outcome | Total run cost divided by outcomes that passed | Rising while completion rate holds steady |
Read them together rather than in isolation. Falling completion alongside rising human-touch points at retrieval or an under-specified step. Steady human-touch with good completion often means the final step is deliberately manual, which is a legitimate design if you named it as one. Rising cost with steady completion points at inefficiency inside a step rather than a defect in the design. Measuring AI workflow success covers how to separate those three causes before rewriting anything.
How to apply this
- Write the outcome and its completion condition before any prompt. If it takes more than a sentence, the scope is wrong.
- Decompose, then check every step has one job and a verifiable completion condition.
- Audit for idempotency specifically on anything that writes, sends or charges, and add the guard before the first live run.
- Add checkpoints and a resume path, then deliberately fail a run in staging to confirm it resumes correctly.
- Only then consider splitting across employees, and define the handoff contract first. Choosing your first AI workflow covers which one to start with; multi-agent workflows explained covers when several are the right answer.
Sources and further reading
- Anthropic: Building Effective Agents: workflow and agent patterns from production use.
- NIST AI Risk Management Framework: a voluntary framework for managing AI risk.
Frequently Asked Questions
How do I start building an AI workflow?
Write the outcome and its completion condition in one sentence before you write any prompt. Then decompose it into steps of three to seven tool calls, give each one job, and define what verifiable result means for it. Most stalled workflow projects stall at step one because the outcome was never specified precisely enough to check.
What does idempotent mean for an AI workflow step?
Running the step twice leaves the same end state as running it once. Reads already satisfy this. Anything that writes, sends or charges does not, unless you design it that way — key generated output on a stable id, overwrite a known path rather than appending, and check a log before retrying an action whose response might have been lost.
Why do AI workflows fail between AI employees rather than inside a step?
Because a handoff usually has no contract. The receiving employee gets prose instead of a defined input shape and improvises, and the sender cannot tell whether the result is usable. Define the input shape, the output shape, a validation step that rejects malformed results, and an owner for repeated failure before you split work across employees.
How should a workflow handle a step that partially completes?
Make the step atomic from the system's perspective even when it is not atomic from the model's: write intent, act, then write confirmation, so a timeout leaves a record you can reconcile. Where that is not possible, record the partial state in the checkpoint and give the human a resume affordance rather than a blind retry button.
Should one AI workflow use one employee or several?
Start with one. A single employee with a longer workflow is almost always better than three employees with an undefined interface, because coordination cost is paid on every run. Split only when each part has a genuinely different toolset or judgement, and only after the handoff contract — input shape, output shape, validation, failure owner — exists.