# The AI Agent node explained

> Understand how n8n's AI Agent node works, what its chat model, memory and tools do, and how to configure an agent that stays reliable.

Source: https://viralistic.nl/help/n8n/ai-agent-node

The AI Agent node puts a language model, such as Claude, inside your workflow and lets it decide which tools to use to finish a task. It is the heart of most AI automations in n8n. This article explains its parts, the settings that matter, and how to keep an agent predictable.

## Agent or regular nodes?

A regular workflow follows fixed rules: if this, then that. An agent reads the situation and chooses its own steps. That is powerful for messy input, like free-text emails or customer questions, but it is slower, costs model usage and is less predictable.

Use an agent only for the parts that need judgement. Keep everything else in regular nodes. [Turn a business process into an agentic workflow](https://viralistic.nl/help/n8n/business-process-to-agentic-workflow) explains how to draw that line.

## The parts of an agent

The AI Agent node is a root node with connectors underneath for sub-nodes:

| Connector  | What it is                                                                                 | Required          |
| ---------- | ------------------------------------------------------------------------------------------ | ----------------- |
| Chat Model | The language model that does the thinking, for example the Anthropic Chat Model for Claude | Yes               |
| Memory     | Remembers earlier messages in a conversation                                               | Only for chat     |
| Tools      | Actions the agent may take: app nodes, HTTP requests, sub-workflows, MCP servers           | Yes, at least one |

### Chat model

Pick a model and a credential for it. For Claude, add the **Anthropic Chat Model** sub-node with an Anthropic API key. On n8n Cloud, some models can also run on n8n's own prepaid credits instead of your key. Faster, cheaper models are often good enough for sorting and extraction. Use stronger models for reasoning and writing.

### Memory

Memory matters for chatbots that hold a conversation. **Simple Memory** is fine for testing. For production, use a memory backed by a database, such as Postgres or Redis, so conversations survive restarts. One-off tasks, like classifying a single email, need no memory.

### Tools

Tools are where the agent gets its power. Common choices:

- **App nodes as tools:** Gmail, Google Sheets, Slack and hundreds more.
- **HTTP Request tool:** call any API.
- **Call n8n Workflow Tool:** run one of your own workflows as a tool. Good for complex, tested logic.
- **MCP Client Tool:** use tools from an external MCP server. See [Use the n8n MCP server](https://viralistic.nl/help/n8n/n8n-mcp).

Give every tool a clear name and description. The agent chooses tools based on those descriptions, so "Look up a customer by email in HubSpot" works far better than "HubSpot1".

> **Tip:** Inside a tool, you can let the model fill a field with `$fromAI()`, for example `{{ $fromAI('email', 'The customer email address') }}`. Fields you fill yourself stay fixed, which is safer.

## Key settings

### Prompt

The prompt is the task for this run. With **Take from previous node automatically**, the agent expects a `chatInput` field, as a Chat Trigger provides. With **Define below**, you write the prompt yourself and pull in data with expressions:

```text
Classify this email and draft a reply.
From: {{ $json.from }}
Subject: {{ $json.subject }}
Body: {{ $json.text }}
```

### System message

Found under options. This is the agent's job description: role, rules, tone and limits. Be specific:

```text
You are the intake assistant for Viralistic support.
Only answer questions about website hosting and email.
Never promise refunds or deadlines. If unsure, hand over to a human.
Reply in the language of the customer.
```

### Output format

Turn on **Require Specific Output Format** and connect an output parser when the next node needs structured data, such as `category`, `priority` and `draftReply`. Structured output is much easier to route with an IF or Switch node than free text.

### Other options

- **Max Iterations** limits how many steps the agent may take (10 by default). This stops runaway loops.
- **Return Intermediate Steps** includes the agent's tool calls in the output. Useful for debugging and logging.

## Human review for risky tools

You can require a person to approve specific tool calls before they run, for example sending an email or deleting a record. Open the tools connector on the agent and add a human review step with a channel such as Slack, Telegram or n8n Chat. The workflow pauses until someone approves or denies.

> **Warning:** Do not give an agent tools it does not need. Every extra tool is something it can misuse. Start with read-only tools, and add write actions behind human review.

## Test your agent

1. Add a **Chat Trigger** while building and use the chat panel to talk to the agent.
2. Open the agent's output and logs to see which tools it called and why.
3. Try awkward input: empty messages, other languages, attempts to make it break its rules.

## Next steps

- [Turn a business process into an agentic workflow](https://viralistic.nl/help/n8n/business-process-to-agentic-workflow)
- [Use the n8n MCP server](https://viralistic.nl/help/n8n/n8n-mcp)
- [Error handling and alerts](https://viralistic.nl/help/n8n/error-handling)
