n8n memory node tip: avoid doubling your AI agent's token cost
By default, every message sent to an AI agent built in n8n is treated as a brand-new call with zero memory of what came before — which is why asking "what did I just tell you?" gets a blank response. The fixes this by sitting next to the AI Agent, keeping a rolling log of recent exchanges, and injecting that history into every request; adding it takes about five seconds. Two things commonly trip people up.
First, the Length setting counts exchanges, not individual messages — one exchange means one user message plus one AI reply. The default value of 5 actually sends 10 messages to the LLM on every single call, and raising it to 10 means sending 20 messages' worth of tokens each time, which adds up quickly in both cost and response latency. For short, task-focused bots, dropping the value to 3 keeps usage lean.
Second, triggering the agent from a webhook or schedule instead of a chat trigger causes a "no " error, because the memory node can't tell which conversation it belongs to. For testing, typing a static value into the Session Key field works fine; for , a unique value per request — a user's email, a Telegram chat ID, or similar — should be mapped in instead.
Key points
- By default every request to an n8n AI agent has no memory of prior messages
- The stores recent exchanges and injects them into each new request
- Length counts exchanges (message pairs), not individual messages
- The default of 5 sends 10 messages per call; raising it to 10 sends 20 messages' worth of tokens
- Webhook or schedule need a unique Session Key per request to avoid a error