New Tool Radar

AI Agents & Automation

How to Fix an n8n AI Agent That Forgets the Previous Message

Work through the memory slot, session key and context window in order to find why an n8n AI agent forgets the previous message.

Schematic diagram with three steps: Check the memory slot, Check the session key, then Raise the window.

An n8n agent that forgets the previous message usually has a memory setup problem, not a model problem. The three places to check, in order, are whether a memory node is attached at all, whether the session key is stable, and whether the context window is long enough.

Before you start

You need the workflow open in n8n and one failing chat to reproduce: a first message with a detail, then a follow-up that depends on it. Run the same two messages three times so you know the failure repeats.

Check the memory slot, then the session key

Open the AI Agent node and look at the Memory slot. If it is empty, attach Simple Memory and retest. If a memory node is attached, check its Session Key: it must come from the Chat Trigger sessionId, or from another stable value such as a Slack thread identifier. A key that changes on every message gives the agent a fresh memory each time, which looks exactly like forgetting.

Check the context window, then the trigger

If the agent remembers the last message but forgets one from five turns ago, the Context Window Length is too short: the default keeps the last 5 interactions. Raise it and retest. If the agent forgets even the previous message with memory attached and a stable key, check the trigger: a Manual Trigger or a webhook that sends no session value gives the memory node nothing stable to bind to.

Worked example: Diagnosis table for a fictional support agent

Northwind Support is a fictional help desk. Its agent forgot order numbers between messages. The table lists each symptom, the likely cause, and the fix to try first.

Symptom Likely cause Fix to try first
Forgets everything, every message No memory node attached Attach Simple Memory to the Memory slot
Remembers in one chat, forgets in the next Session key changes each run Bind the key to the Chat Trigger sessionId
Remembers the last message only Context window is 5 and the chat is longer Raise Context Window Length toward 20
Forgets after a workflow redeploy Memory lives in the n8n process Move to Postgres or Redis memory

Expected result (UNTESTED): after the fix, the same two-message test passes three times in a row, and a six-turn chat keeps the detail from turn 1. We checked the n8n tutorial, which records the Simple Memory defaults and the sessionId binding, but we did not run the failing workflow on a live n8n instance.

Limits

This guide fixes setup causes of forgetting. It does not fix a model that ignores the memory it is given, and it does not make Simple Memory durable across restarts. If the agent still forgets with a stable key and a long window, read the execution log to see whether the memory node returned the history at all.

Sources

See all