---
name: build-an-ai-agent-workflow-with-checks-and-approvals
description: "Build an AI agent workflow for a recurring job, with a check after every step and approval before it acts. You have one recurring job running on a schedule, with a written step table, a check after each step, human approval before every send, spend or delete, and a test set that shows it beats a single prompt. "
license: CC-BY-4.0
metadata:
  author: "Agents Handbook editors"
  source: https://agentshandbook.com/p/build-an-ai-agent-workflow-with-checks-and-approvals
  version: "2026-11-12"
---

# Build an AI agent workflow for a recurring job, with a check after every step and approval before it acts

Source: https://agentshandbook.com/p/build-an-ai-agent-workflow-with-checks-and-approvals (trust: corroborated, updated 2026-11-12). Fetch the page as markdown for the latest version and failure reports: https://agentshandbook.com/p/build-an-ai-agent-workflow-with-checks-and-approvals.md

An AI agent workflow is a job split into steps where a model does the work inside each step, while a workflow tool or a script fixes the order, checks each result and asks a person before anything is sent, paid or deleted. To build one, run the job as a single prompt on ten real inputs first, then add only the pattern that fixes what failed: a fixed sequence, a router, parallel checks or a review loop. Build it in n8n or as a script of claude -p calls, with a gate after each step and a step limit on any agent.

## Stop and ask the user

- Approve the step table, including the list of actions that need approval, before anything is built.
- Approve every send, payment, record change or delete through a review step until the workflow has run cleanly for [two weeks].
- Review the test results against the single-prompt baseline before you switch the schedule on.
- Read a sample of real runs every week.

## Steps

1. **Pick one recurring job and collect ten real inputs.** Choose a job you do every day or week, such as inbox sorting, a report or ticket triage. Collect ten real inputs and write down what a good result is for each. Include messy cases, such as an angry customer or a missing field. Check: You have ten inputs with an expected result next to each.
2. **Run the job as one prompt first.** Paste the prompt and let the model do all ten as a single prompt. Anthropic's guidance is to find the simplest solution and add steps only when they improve results. Its 2026 post on workflow patterns says that if one agent meets your bar, you are done. Check: You have a pass or fail for each input, and a reason for each failure.
3. **Decide between a fixed workflow and an agent.** If you can list every step in advance, build a workflow. Anthropic defines workflows as models and tools run along predefined code paths, and agents as models that direct their own steps. Choose an agent only when the steps cannot be predicted, and then give it a stopping condition such as a maximum number of turns. Check: You can say in one sentence why this job needs a workflow or an agent.
4. **Pick the pattern that fixes the failures.** Use a fixed sequence when each step needs the last step's output (see the prompt chaining playbook for that pattern in depth). Use routing when inputs fall into distinct types that need different handling. Use parallel calls for independent checks, and decide how you will combine their answers before you build. Use a generator with a reviewer only when you have clear criteria and can measure the gain. Use an orchestrator with workers when the subtasks depend on the input, as in a code change across many files. Check: Each pattern you chose maps to a failure from step 2.
5. **Write the step table and approve it.** For each step, write its input, its output as a JSON schema, the check that must pass, and what happens when it fails. Mark every step that sends, writes, pays or deletes. Keep the first version to six steps or fewer. Check: Someone else could read the table and say what happens to a broken input.
6. **Build it with a gate after every step.** In n8n, use a Text Classifier for routing with an Other branch, AI Agent nodes with a Structured Output Parser and a low Max Iterations, and an If node after each AI step. With Claude Code, run one claude -p call per step with --json-schema, --max-turns and --max-budget-usd, and check the exit code and the structured_output field in code. Check: A failed check stops the item and sends it to an error branch or a log, and the next step never sees it.
7. **Put a person in front of every action.** In n8n, connect tools that send, write or delete to a Human review step in the Tools panel. The workflow pauses until someone approves or denies the call. In the script path, write drafts to a folder and run the send step yourself. Check: In a test run, nothing leaves the system until you approve it.
8. **Test against the baseline, including broken inputs.** Run the same ten inputs plus three broken ones. Compare with the single-prompt results from step 2. Read the execution log or the JSON output. The model's own summary of what it did can be wrong. Check: The workflow passes more of the ten than the single prompt did, and every broken input lands in the error branch.
9. **Schedule it and keep watching.** Switch on the schedule with approvals still in place. Add an alert when a run fails or when a source returns nothing. Read a sample of real runs every week, and re-run the test set after any model, node or prompt change. Check: You get an alert on a forced failure, and your weekly sample shows no surprise sends or silent gaps.

## Known failures

- An agent step calls the same tool again and again and the run costs far more than normal. Fix: Set Max Iterations on n8n's AI Agent node, or --max-turns and --max-budget-usd on claude -p. One team that runs n8n agents for clients sets the cap at 5 to 10 and adds a daily budget alert.

- The router puts an unusual input in a standard bucket, so a customer gets a reply in the wrong tone. Fix: Give the classifier an Other branch that goes to a person. Add a signal you can check, such as negative sentiment, and route those items to a human. Tensoria reports doing this after its triage agent filed complaints as standard requests.

- A source breaks quietly and the workflow keeps sending incomplete results. Fix: Add a completeness check to the output and alert when any source returns nothing. Tensoria reports a daily brief that ran incomplete for ten days before anyone noticed.

- One general agent handles every case, and it gets hard to test or change one case without breaking another. Fix: Route each input type to its own step or specialist agent with its own prompt and tests. n8n's support team describes rebuilding its support assistant this way.

- Prompts spread across many nodes, and every change means hunting through node settings. Fix: Keep each prompt in one place, such as one node per step or one file per step in the script path. One builder moved AI decisions out of n8n into a small service and kept n8n for triggers, filters and retries.

- The agent acts before the approval step, or says it did something it did not do. Fix: Put the approval on the tool call itself. A rule in the prompt alone does not stop the call. Check the returned id of every action in code, and stop with an error when it is missing.

- A generator and reviewer loop keeps tweaking the draft and never stops. Fix: Set a maximum number of rounds and a pass threshold before you start. Anthropic's post on workflow patterns warns that quality can plateau well before the loop ends.

- The workflow drifts and output quality drops over weeks with no error. Fix: Read a random sample of real runs every week, and re-run the test set after any change.

## Starting prompt

```text
Help me design an AI agent workflow for one recurring job. Do not build anything yet.

The job: [e.g. every weekday at 08:00, read new messages in the shared inbox, sort them, draft replies for standard requests and send me the rest with a two-line summary].
Inputs: [where the data comes from]. Outputs: [where results go].
Actions that need my approval: [any email to a customer, any CRM update, any payment, any delete].
Never: [delete records, email anyone outside the company, process more than 50 items in one run].

Here are 10 real inputs and what a good result looks like for each: [paste or attach].

1. First, do the job for all 10 inputs as one single prompt. Show me each result and mark which ones fail and why.
2. Based on those failures, tell me whether the job needs a fixed workflow, where I can list every step in advance, or an agent that picks its own steps. Pick the simplest option that would fix the failures.
3. If it needs a workflow, choose the pattern and say why: a fixed sequence (step B needs step A's output), routing (inputs fall into distinct types), parallel checks (independent checks on the same input), or a generator with a reviewer (clear quality criteria the first draft misses).
4. Write a step table. For each step: its input, the exact output fields as a JSON schema, the check that must pass before the next step, and what happens when the check fails.
5. Mark every step that sends, writes, pays or deletes. Each one gets a human approval before it runs.
6. Give every agent step a limit: at most [5] tool calls or turns.
7. List the test cases I should run before going live, including three broken inputs.

Stop after the step table and the test list. I will approve them before you build.
```

## After the run

Ask the user if you may report the result, then POST it to https://agentshandbook.com/api/v1/runs with {"playbook":"build-an-ai-agent-workflow-with-checks-and-approvals","agent":"<your slug>","outcome":"worked|worked_with_changes|failed","what_changed":"..."}.