A8gent
n8n AI Foundations · Lesson 2 of 13

The AI Agent Node Explained

The AI Agent node is the core of AI work in n8n. Learn what it does, the sub-nodes it connects to, and when to use it over a plain model call.

What the AI Agent node actually does

The AI Agent node in n8n is a cluster node that lets a language model decide which tools to call to complete a task, rather than following a fixed sequence you hardcoded. You give it a goal and a set of tools, and the model reasons about which tool to use, reads the result, and decides the next step until it has an answer. This is the difference between a fixed automation and an agent: the agent chooses its path.

The sub-nodes it needs

The AI Agent node has connection points along its bottom edge for the pieces it depends on.

  • Chat Model: the language model that does the reasoning, such as an OpenAI or Anthropic model connected with your credentials. This connection is required.
  • Memory: an optional store that lets the agent remember earlier messages in a conversation, covered in a later lesson.
  • Tool: one or more tools the agent may call, such as an HTTP Request tool, a Google Sheets tool, or a Call n8n Workflow tool. You can attach several.

Agent node versus a plain model call

n8n also offers a Basic LLM Chain node that just sends a prompt to a model and returns the answer, with no tool use. Reach for that when the task is a single decision like "classify this message" or "summarize this text." Reach for the AI Agent node when the task genuinely needs the model to gather information or take actions through tools before it can answer. Do not use an agent where a single model call would do, because the agent is slower, costs more, and is harder to predict.

Writing the system prompt

The agent's behavior is shaped by its system prompt, set in the node's options. Be specific about its role, the rules it must follow, and when it should stop and hand off. A vague prompt produces an agent that wanders or invents answers.

  1. State the role clearly: "You are a support triage assistant for a software company."
  2. List the hard rules: what it must never do, and when to escalate to a human.
  3. Tell it to say it does not know rather than guess when a tool returns nothing useful.

What good looks like

You can look at a task and say whether it needs the AI Agent node or just a single model call. When you do use the agent, its system prompt is specific and its tools are scoped to exactly what the job requires.

Common mistakes

  • Using the AI Agent node for a task a single Basic LLM Chain call would handle more cheaply and reliably.
  • Attaching many broad tools, which makes the agent's choices harder to predict and debug.
  • Leaving the system prompt vague, so the agent guesses instead of following your rules.