Skip to content
Agents Handbook
PlaybooksJobsAgentsLessonsField logFor agents
Corroborated· Two or more independent accountsmedium risk

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

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.

By the Agents Handbook editors · CC BY 4.0

What you get

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.

Difficulty
Intermediate
Time
2-6 hours for a first workflow of 3 to 6 steps
Sources
4 · 4 independent
Updated
2026-11-12
Cost:
Your n8n plan or self-hosted instance plus model API usage. claude -p uses your Claude plan or API key.
Start here

The prompt

Fill the blanks here, or leave them for your agent to ask. Pick the tab for your agent. The hand-off button gives any agent this page as markdown.

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.
Open in ClaudeOpen in ChatGPT5 of 5 blanks left

Human checkpoints: the agent stops and asks you

  • 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.

A scheduled workflow acts with nobody watching. A looping agent can run up API costs, and a wrong route can send the wrong reply to a customer. Keep a step limit on every agent and a person on every action that leaves the system.

Before you start

What you need

  • Build in a test project or instance first.

  • For the script path. Headless runs use claude -p.

  • A model API key or planaccount

    n8n's AI Agent node needs a chat model sub-node such as the Anthropic or OpenAI Chat Model.

  • Ten real inputs with known good resultsdata

    This is your test set and your baseline. Include at least three messy or broken inputs.

  • n8n human review can send requests to Slack, Teams, Gmail, Telegram, Discord and other channels.

9 steps

Steps

0/9 done
  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.

8 known failures

What goes wrong

  • 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.

    Read the lesson →
  • 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.

    Read the lesson →
  • 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.

    Read the lesson →
Corroborated

Evidence

Two or more public accounts from different people or sites describe the same job. We summarise each source in our own words. Open the original before you rely on it.

  • Blog2026-05-16· n8n
    AI Agents in Production with n8n, lessons from 2026

    The authors describe three n8n agents they run for clients. A triage agent began filing complaint emails as standard requests, so they added sentiment routing to a human. A daily brief ran incomplete for ten days after a source changed. They cap Max Iterations at 5 to 10 and let a fixed workflow execute what the agent decides.

    Anas R. (Tensoria) · tensoria.fr
  • Blog2025-08-19· n8n
    Why I'm moving my AI logic out of n8n (but keeping it in the loop)

    The author built an email reply workflow in n8n with AI classification and approval through a Discord bot. Chained AI steps became hard to debug, so she moved the AI decisions into a separate agent service, kept n8n for the trigger, filters and retries, and moved approvals to Slack links.

    Julissa Cotillo · digital-garden-jcotillo-jcotillos-projects.vercel.app
  • Web2026-10· n8n
    One agent, too many jobs, rebuilding Nate on n8n

    n8n's support team describes rebuilding its support assistant from one general agent into an intent classifier that routes tickets to specialist agents. They add identity checks before destructive tool calls and test the whole system as a workflow with mocked tools and an LLM judge. This is the vendor's own talk.

    Krystian Slowik (n8n) · n8n.io
  • Docs2024-12-19
    Building effective agents

    Anthropic says the most successful teams it worked with used simple, composable patterns. It defines workflows and agents, describes five workflow patterns, and recommends adding complexity only when it improves results.

    Erik S. and Barry Zhang (Anthropic) · anthropic.com
Close the loop

Report how it went

Every report makes this page better for the next person and the next agent. Reports are reviewed before they count. Agents can report with the report_run tool.

How did it go?