The n8n AI Agent node with Claude: model + memory + tools in one drag-and-drop block
TL;DR
n8n's AI Agent node takes input (chat, webhook, schedule), uses a chat model (e.g. Anthropic/Claude) and can attach memory and multiple tools. The agent decides which tool to call. Keep tools few and well described, write a tight system message, log every run.
In n8n you can build a complete agent without writing code: drop in the AI Agent node, plug in a chat model (Claude), attach memory, add a few tools — and the agent decides which tool to call to finish the job. This article explains the structure, how to configure it with Claude, an order-lookup assistant example, and the common mistakes that make agents loop and burn tokens.
Structure: one root node, several sub-nodes
AI Agent is a “root node” with ports for sub-nodes:
| Block | Choose | Notes |
|---|---|---|
| Trigger | Chat Trigger, Webhook, Schedule, email… | Where requests come from |
| AI Agent | Tools Agent (the recommended default) | The orchestrating brain |
| Chat Model | Anthropic Chat Model | The credential (API key) and model choice live on this node, not on the Agent |
| Memory | Simple/Window Buffer, Postgres Chat Memory, Redis Chat Memory… | Keeps conversation context per session; skip it for single-run workflows |
| Tools | HTTP Request, Code, Postgres, Google Sheets, Workflow Tool, Think… | Each tool has its own credentials; the Agent holds none |
| Output Parser (optional) | Structured / Auto-fixing Output Parser | Forces output into a JSON schema |
Build steps
- Add the AI Agent node and choose Tools Agent.
- Connect an Anthropic Chat Model to the Model port; create a credential with a Claude Console API key and pick a model (Haiku for simple work, Sonnet/Opus when reasoning matters).
- Write the System Message (standing rules) and the Prompt (usually an expression pulling data from the previous node, such as the chat message).
- Attach tools to the Tools port.
- Attach memory for multi-turn conversations.
- Set Max Iterations and enable Return Intermediate Steps while debugging.
Example: an order-lookup assistant for customer support
Chat Trigger (support agent asks in an internal chat)
→ AI Agent (Tools Agent)
├─ Model: Anthropic Chat Model (Sonnet)
├─ Memory: Postgres Chat Memory (per support-agent session)
├─ Tool: Postgres "find_order" — look up by order ID or phone number
└─ Tool: HTTP Request "track_shipment" — call the carrier's API
→ reply in chat + log to Google Sheets
Sample System Message:
You are an order-lookup assistant for customer-support staff.
- Only answer questions about orders and shipping.
- Always look things up with tools; never guess a status.
- Never show a customer's full phone number or address; last 3 digits only.
- If unsure, say "not found" and suggest re-checking the order ID.
- Reply in at most 5 lines, with the order ID and latest status.
Write tool descriptions like docs for a colleague
The agent chooses tools from their descriptions. “Database tool” is close to useless. Compare:
Weak: "Database tool"
Strong: "Find an order by order ID (format DH123456) or phone number.
Returns: order ID, order date, status, tracking number.
Use when staff ask about a specific order."
Rules of thumb: one job per tool; state inputs, outputs and when to use it. To reuse complex logic, package it as its own workflow and attach it with the Workflow Tool.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
| The agent loops until the limit | It lacks the information to finish | Lower Max Iterations (default 10; 5–8 during development), add the Think Tool, say “if nothing is found, stop and report” |
| Wrong tool chosen | Vague descriptions, too many tools | Rewrite descriptions, remove tools |
| Inconsistent output | Free-text answers | Add a Structured Output Parser with a schema |
| Downstream nodes break with intermediate steps on | Output gains an intermediateSteps array | Normalise to the output field with a Code node |
| Bills climb fast | Big models for simple jobs, many iterations | Haiku for simple tasks, cap iterations, monitor usage in the provider dashboard |
Safety
- Write tools (deleting, refunding, emailing customers) belong behind a human-approval step — for example Slack “Send and Wait for Response”.
- Give tool credentials minimal rights: lookup tools use a read-only DB user.
- If the agent reads customer content (email, chat), treat it as untrusted input — it may contain prompt injection.
- Watch the Executions tab to spot loops and errors early.
How to apply it
- Developers: Start with 1–2 read-only tools, turn on intermediate steps to see what the agent “thinks”, and refine tool descriptions until tool choice is reliable.
- Tech Leads: Standardise a system-message template (role, limits, output format) and an approved tool list for internal agents.
- PMs: An n8n agent is the fastest way to test an internal-assistant idea in a few hours — prove the value before investing in code.
Sources & references
- n8n Anthropic Chat Model node: connect Claude to your AI Agent workflows — DEV Community
- Build AI agents with n8n — Strapi Blog