
An AI agent built in n8n holds up in production when the workflow around it expects failure. Run n8n in queue mode on Postgres, keep the agent's chat history in Postgres, give every node that calls a model or an API a retry and an error path, set an error workflow that alerts a person, and have a second agent check each draft before it reaches the user, with a person approving any tool call that sends, writes or deletes. Every draft is then checked before it ships, and a failed run reaches a person instead of disappearing. Pinkcube's chat agent, which Ovidius built on n8n, has a second agent that checks every draft before the customer sees a word.
A prototype that works on the canvas meets different conditions in production. A webhook fires in the middle of the night, the model returns malformed JSON, an API answers with a rate limit or times out, and the run fails with no alert, no retry and no record anyone reads, so your team hears about it from a customer the next morning. n8n has a setting or a node for each of these failures.
Self-hosting n8n in your own cloud account keeps the editor, your credentials and every execution log on infrastructure you control. For production volume, run it in queue mode. In n8n's queue mode documentation, "The main n8n instance handles timers and webhook calls, generating (but not running) a workflow execution", and Redis holds the queue of pending executions so the next available worker picks each one up. You switch it on by setting EXECUTIONS_MODE to queue on the main instance and every worker, and you add workers as volume grows, so one slow workflow does not hold up the rest.
Move the database to Postgres before you switch queue mode on. By default n8n saves credentials, past executions and workflows in SQLite (n8n's database settings), and the queue mode page says that running queue mode "with an SQLite database isn't recommended". Postgres also gives the agent a place to keep its chat history, which the next section needs.
For regulated data, where n8n runs decides which agreements apply: self-hosted in your own AWS or Google Cloud account, it runs under the business associate agreement you hold with that provider. Prune execution data on a schedule, so personal data does not pile up in the logs.
The AI Agent node sits at the centre of the workflow. Per n8n's AI Agent node documentation, you "Connect a chat model and one or more tools, and the agent decides which tools to call to complete a task", and you must connect at least one tool sub-node. The chat model can be Claude, an OpenAI model or a model you host.
Memory needs a different node in production. Simple Memory, the node earlier n8n versions called Window Buffer Memory, keeps chat history in the workflow, and on a queue-mode instance it "doesn't work in an active production workflow", because n8n can't guarantee that every call reaches the same worker (Simple Memory documentation). Postgres Chat Memory stores the history in a Postgres table instead, so every worker reads the same conversation, and its Context Window Length sets how many previous interactions the agent sees (Postgres Chat Memory documentation).
A production build sets up each of these nodes before the agent sees live input:
Plan for every external dependency to fail at some point, and give each failure its own branch. Turn on Retry On Fail for each node that calls a model or an API: "When an execution fails, the node reruns until it succeeds" (n8n's node settings). Where a retry will not fix the failure, set the node's On Error to Continue (using error output), which passes the error information to the next node, so a branch of your own handles it. Check the model's output before the next step uses it, and when it does not parse, fail the run on purpose with the Stop And Error node, which starts the error workflow.
A failed run then has to reach a person. Per n8n's error handling documentation, you set an error workflow for each workflow in Workflow Settings, it "runs if an execution fails", it must start with the Error Trigger, and one error workflow can serve many workflows. Have it send a Slack or email alert to a person, and log each run's metadata to Postgres, so you can trace a failure without replaying the whole workflow.
Build the guardrails into the first version, before launch. A second agent reads each draft the AI Agent node writes and checks it against your rules before anything reaches the user. A draft that passes goes out as the reply to the user, and a draft that breaks a rule goes back for a rewrite, with the violation and the fix. At Pinkcube the second agent, the Gatekeeper, passes a draft or sends it back up to ten times, and only text the Gatekeeper passes reaches the customer (the Pinkcube case study).
An action needs a check of its own, before it runs. n8n lets you "require human approval before an AI Agent executes a specific tool", on all of the agent's tools or only the ones you choose. The reviewer approves or denies the request in n8n's chat, in Slack or by email; approval runs the tool with the input the agent gave, and a denial cancels the action and tells the agent (n8n's human-in-the-loop documentation). Use it for any tool that sends, writes or deletes. For an approval step outside the agent, the Wait node pauses the run, offloads the execution data to the database and resumes when it receives an HTTP call (Wait node documentation).
Ovidius builds AI agents on self-hosted n8n in your cloud, behind your own sign-in. A failed step retries, then alerts your team in Slack and by email, and where a wrong answer would cost money or trust, a second AI model reviews each output before it goes out. A senior partner scopes the first agent with you, and the scope gives you the timeline before you commit.
Pinkcube sells branded merchandise to Dutch and Belgian businesses, and its chat desk was staffed 45 hours a week. The agent Ovidius built on n8n answers in Dutch or English, checks live order status and files a pre-sorted HubSpot ticket when it cannot help, and now covers all 168 hours of the week. Before launch it faced 76 hostile test scenarios, and 64 of them scored 5 out of 5. The chat agent has no ticket permissions at all. A separate triage agent reads the finished conversation and creates the ticket wherever the chat agent made a promise (the Pinkcube case study).
The second build is a content pipeline for an e-commerce product customisation platform that wanted to rank for hundreds of long-tail keywords without adding headcount. Ovidius designed and built a pipeline of AI agents on n8n: research agents pull keyword, competitor and search result data, a brief agent sets the structure, and content agents write, check and polish the article. A keyword becomes a publish-ready article in 29 minutes, in about 33 n8n executions (the case study).
In both builds, n8n orchestrates every step and a check runs before a customer or a reviewer sees the output: the Gatekeeper at Pinkcube, and the content agents' fact-checking passes in the content pipeline. Before you build, check that n8n fits your job. Ovidius's platform comparison scores eight platforms against the same four jobs, and rates n8n a good fit for an agent that works through a queue of tasks.
It connects a chat model to one or more tools, and the agent decides which tools to call to complete a task, as n8n's AI Agent node documentation puts it. You must connect at least one tool sub-node, and the chat model can be Claude, an OpenAI model or a model you host. In production it also takes a memory sub-node that keeps chat history in Postgres.
No. On a queue-mode instance, Simple Memory does not work in an active production workflow, because n8n can't guarantee that every call reaches the same worker. Use Postgres Chat Memory instead: it stores chat history in a Postgres table that every worker reads, and its Context Window Length sets how many previous interactions the agent sees.
SQLite. By default n8n saves credentials, past executions and workflows in SQLite, and it also supports Postgres. n8n's queue mode documentation says running queue mode with an SQLite database isn't recommended, so move to Postgres before you set EXECUTIONS_MODE to queue on the main instance and every worker.
Set an error workflow. In the workflow's Workflow Settings, choose an error workflow that starts with the Error Trigger. Per n8n's error handling documentation, n8n runs it when an execution fails, and you can point other workflows at the same error workflow. Have it send a Slack or email alert to a person. To fail a run on purpose, for example when the model's output does not parse, add the Stop And Error node.
Yes. n8n can require human approval before an AI Agent executes a specific tool, on all of its tools or only the ones you choose. The reviewer approves or denies the request in n8n's chat, in Slack or by email. Approval runs the tool with the input the agent gave, and a denial cancels the action and tells the agent. Use it for any tool that sends, writes or deletes.
It goes back to the AI Agent node for a rewrite, with the violation and the fix, and only a draft that passes goes out as the reply to the user. In the Pinkcube case study, the second agent, the Gatekeeper, checks every chat reply this way and can send a draft back up to ten times before the customer sees a word.
Building an AI agent on n8n?
Book a discovery call. A senior partner leads your workflow from the first call and scopes the first agent with you.