AI Automation

How an n8n AI Agent Works: The Parts and the Loop

How an n8n AI agent works: chat model, memory, tools and the decide-act loop, with a lead triage example and the limits to set before it touches real data.

  • By
  • Updated
  • 3 min read
  • Facts checked
Short answer

An n8n AI agent is a workflow node that connects a language model, optional memory and a set of tools. It reads the input, decides which tool to call, reads the result, and repeats until it can answer or finish the task. n8n handles the plumbing, triggers and credentials; you control what tools exist and what each may do.

Part of the guide: AI Automation in Malaysia: The 2026 Guide for SMEs

On this page
  1. What are the parts?
  2. What is the loop?
  3. What does it look like in practice?
  4. Where do you put safety limits?
  5. How does MCP fit in?
  6. What should you do next?
  7. Sources
  8. Frequently asked questions

The agent part of n8n is a thin layer on top of the workflow engine you already use for automation. Understanding the layers makes it easier to put safety limits in the right place.

Part of the guide: AI automation in Malaysia. Node names and options change between n8n versions; check docs.n8n.io for the version you run. Checked 22 October 2026.

What are the parts?

Part What it does Your decision
Trigger Starts the run: WhatsApp message, email, webhook, schedule Which events may start it
Agent node Holds the instructions and runs the loop What the job is, in plain words
Chat model The language model that reasons Which model, and where it processes data
Memory Remembers earlier messages in a chat How much, and how long it is kept
Tools Actions the agent may choose: search, look up, create Which tools, read or write
Output Reply or result sent onward Who sees it, and whether a person approves

What is the loop?

  1. The agent receives the input and its instructions.
  2. The model decides: answer now, or call a tool.
  3. If it calls a tool, n8n runs it and returns the result.
  4. The model reads the result and decides again.
  5. It stops when it has an answer, or hits the step limit you set.

Set a maximum number of steps. A loop with no limit can burn money on a confused request.

What does it look like in practice?

Illustration for a KL services firm: a lead triage agent.

  • Trigger: a new WhatsApp enquiry.
  • Tools: find_contact (read CRM), create_deal (write CRM), notify_sales (send internal alert).
  • Instructions: classify the enquiry (quote, support, other), extract company and need, create the deal only for quotes, never reply to the customer with prices.
  • Control: a rule outside the agent drops deals above a value limit into approval.

The agent decides which of the three tools to use and in what order. The hard limits are not in the prompt; they are in the tool design and the rules around it.

Where do you put safety limits?

In the tools, not in the instructions. If create_deal can only create a deal with certain fields, the agent cannot do more, however it is persuaded. Offering a whole sub-workflow as a tool, with its own checks, is a good pattern. Read Prompt injection: the risk for business agents and the governance checklist.

How does MCP fit in?

n8n can also work with MCP, the standard that lets AI apps use external tools, in some versions both as a client and as a server. See What is MCP, in plain words, and confirm current support in the n8n docs before planning around it.

What should you do next?

Build the first agent read-only, test it on 50 real cases, then add one write tool. The method is in How to build an AI agent for a business. We build and run these for clients; see our software service or book a call.

To build this loop yourself with guardrails, our AI automation and agents course teaches it on n8n, Make or Zapier.

Sources

Frequently asked questions

Do I need to code to build an n8n AI agent?

Not for a basic one. You connect nodes visually and write instructions in plain language. Custom tools, tests and permission design benefit from a developer.

Which AI models can n8n use?

n8n supports models from several major providers and self-hosted models through its chat model nodes. Check the current list in n8n's documentation, because it changes.

Can an n8n agent call other workflows?

Yes, a workflow can be offered to the agent as a tool, which is a safe pattern: the agent chooses the tool, but the workflow decides exactly what happens.

What does an agent run cost?

One n8n execution plus the model's usage fees, which grow with the amount of text and the number of loop steps. Measure cost per run in testing.