Building Multi-Agent Workflows with n8n
How to split an AI workflow into an orchestrator and specialist agents in n8n — sub-workflows as tools, memory, validation, human approval, error handling and scaling with queue mode.
A single AI agent with a long prompt and a dozen tools works well in a demo. In real work it tends to get harder to reason about: the prompt grows, tool choices get less predictable, and when something goes wrong it is hard to tell which part of the job failed.
A multi-agent workflow splits the job. One agent — the orchestrator — understands the request and decides what needs doing. Specialist agents each handle one narrow task with their own instructions and tools. In n8n this maps naturally onto features that already exist: the AI Agent node, sub-workflows, and the tools that let an agent call them.
This article walks through a reference architecture, the n8n building blocks behind it, and the production concerns — validation, approval, errors and scaling — that decide whether it holds up outside a demo.
This is a design guide, not a case study. It describes patterns documented by n8n. Node names and options change between n8n versions, so check the documentation for the version you run.
When one agent is enough
Start simple. A single agent is the right choice when the task is narrow, the tools are few and closely related, and one set of instructions covers every case. Splitting work across agents adds moving parts: more prompts to maintain, more model calls (cost and latency), and more places for data to be lost between steps.
Consider multiple agents when you see one or more of these signals:
- The instructions for different parts of the job conflict, or the system prompt has become a long list of special cases.
- Different steps need different tools, permissions or models — for example, a cheaper model for classification and a stronger one for drafting.
- You want to test, version or reuse one capability (say, “research a company”) in several workflows.
- You need a clear audit trail of which step produced which output.
The reference architecture

The pattern has five parts:
- Trigger — a Webhook (from your app or form) or a Chat Trigger (for conversational use) starts the run and provides the input.
- Orchestrator — an AI Agent node with a chat model, memory and a small set of tools. It plans and delegates; it does not do the specialist work itself.
- Specialists — separate workflows, each with its own AI Agent, prompt and tools, exposed to the orchestrator as tools.
- Guards — deterministic checks on the result (schema, required fields, allowed values) and, for anything sent to customers or written to a system of record, a human approval step.
- Failure path — retries on individual nodes and a separate error workflow that alerts someone and records what happened.
The n8n building blocks
Three n8n features do most of the work: the AI Agent node, sub-workflows, and memory.
The AI Agent node
The AI Agent node is a root node that you connect sub-nodes to: a chat model, optionally a memory, and one or more tools. Current n8n versions run it as a tools agent — the model decides which connected tool to call, reads the result and continues until it can answer. (Older versions let you pick an agent type; n8n’s documentation notes that this option was removed in version 1.82.0.)
Two practical points matter more than any setting:
- Tool descriptions are part of the prompt. The model chooses tools by their name and description. “Research a company: input a company name or domain, returns a short factual profile with source URLs” works far better than “research tool”.
- Keep the orchestrator’s system message about routing. Describe the goal, which specialist handles what, and what the final output must look like. Leave domain detail to the specialists.
Specialists as sub-workflows
Each specialist is its own workflow that starts with the Execute Sub-workflow Trigger (shown in the editor as “When Executed by Another Workflow”). On that trigger you define the input fields the workflow accepts, which gives each specialist a clear contract.
There are two ways to call a specialist:
- From the orchestrator agent, via the Call n8n Workflow Tool sub-node. The agent decides when to call it and passes the inputs.
- From ordinary workflow logic, via the Execute Sub-workflow node — useful when a step should always run, rather than at the model’s discretion.
A specialist’s input contract can be as small as this:
{
"task": "research_company",
"company": "Example Ltd",
"domain": "example.com",
"max_sources": 5
}
And its last node should return one predictable shape — for example { "status": "ok", "summary": "...", "sources": ["https://..."] } — so the orchestrator never has to guess.
Memory: keep it at the edge
Memory sub-nodes (such as the simple, window-based memory) store recent messages keyed by a session ID. The Chat Trigger provides a session ID automatically; with a Webhook you pass your own, for example the user or ticket ID.
A good default is memory on the orchestrator only. Specialists receive everything they need in their inputs and return a result — they stay stateless, which makes them easier to test, reuse and run in parallel. Window-based memory also lives in n8n’s process; if conversations must survive restarts or be shared across instances, use a memory backed by an external store (n8n provides options such as Redis and Postgres chat memory).
Validate before you trust the output
Model output is a suggestion until it is checked. Put deterministic checks between the agent and anything that acts on its result. The AI Agent node’s Require Specific Output Format parameter lets you connect an output parser; a Code node after it can then enforce your own rules:
// n8n Code node — mode: "Run Once for All Items"
// Rejects agent output that is not valid JSON or misses required fields.
const required = ['customer_id', 'intent', 'reply_draft'];
const allowedIntents = ['quote', 'support', 'billing', 'other'];
return $input.all().map((item) => {
let data;
try {
const raw = item.json.output;
data = typeof raw === 'string' ? JSON.parse(raw) : raw;
} catch (e) {
throw new Error('Agent output is not valid JSON');
}
for (const key of required) {
if (data[key] === undefined || data[key] === '') {
throw new Error(`Missing field: ${key}`);
}
}
if (!allowedIntents.includes(data.intent)) {
throw new Error(`Unexpected intent: ${data.intent}`);
}
return { json: data };
});
Throwing an error here is deliberate: it stops the run and sends it down the failure path instead of letting a malformed result reach a customer or a database. For an explicit, readable failure you can also use the Stop and Error node after an IF check.
Human approval for actions that matter
Agents should draft; people should approve anything that is hard to undo — emails to customers, payments, changes in a CRM. In n8n the Wait node can pause an execution until it is resumed, for example by a webhook call or a form submission. A common pattern:
- The workflow sends the draft to a reviewer (email or a chat message) with approve/reject links.
- The Wait node pauses the execution.
- On approval the run continues and performs the action; on rejection it logs the reason and stops.
While it waits, n8n offloads the execution data to its database (except for very short time-based waits), so a pending approval does not tie up a running process. Record the reviewer’s decision in your own log or system as part of the approved branch.
Error handling that tells someone
Agent workflows fail in ordinary ways — an API times out, a rate limit is hit, a model returns nonsense. n8n gives you three layers:
| Layer | n8n feature | Use it for |
|---|---|---|
| Node | Retry On Fail (with max tries and wait between tries) | Transient errors: timeouts, rate limits, flaky APIs |
| Node | On Error: Stop Workflow / Continue / Continue (using error output) | Deciding whether a failed step should stop the run or be handled on a separate branch |
| Workflow | Error workflow that starts with the Error Trigger node, selected in Workflow Settings | Alerting a person and logging the failed execution |
Set retries on the nodes that call external services, route expected failures through the error output, and make sure every production workflow has an error workflow selected. The error workflow should at minimum post to a channel someone watches and include the execution URL.
Scaling: queue mode
By default an n8n instance runs workflows in its main process. When agent workflows become numerous or long-running, n8n’s queue mode separates concerns: the main instance receives triggers and queues executions in Redis, and one or more worker processes run them. Queue mode requires PostgreSQL as the database, and every main and worker instance must share the same encryption key so that credentials can be decrypted everywhere.
# Shared by the main instance and every worker
EXECUTIONS_MODE=queue
QUEUE_BULL_REDIS_HOST=redis
QUEUE_BULL_REDIS_PORT=6379
DB_TYPE=postgresdb
N8N_ENCRYPTION_KEY=<the same secret everywhere>
# Start a worker process
n8n worker
Because specialists are stateless sub-workflows, they spread across workers without special handling. Keep conversation memory in an external store when you run several instances.
A production checklist
- Each specialist has a defined input contract and returns one predictable output shape.
- Tool names and descriptions say exactly what the tool does, what it needs and what it returns.
- The orchestrator’s Max Iterations option is set deliberately, so a confused agent cannot loop indefinitely.
- Memory sits on the orchestrator, keyed by a session ID you control; specialists are stateless.
- Model output is validated by deterministic checks before anything acts on it.
- Customer-facing or irreversible actions wait for human approval.
- External calls have retries; every production workflow has an error workflow that alerts a person.
- Credentials live in n8n’s credential store, never in prompts or Code nodes.
- Queue mode, PostgreSQL and a shared encryption key are in place before load grows.