How does memory work in an n8n AI agent?

Short answer

In n8n, memory is a sub-node you attach to an AI Agent node. It keeps the recent chat history for one session, identified by a session ID, and sends the last few interactions back to the model. Simple Memory keeps it in the workflow data and is not safe in queue mode; Postgres or Redis Chat Memory store it in a database. None is long-term knowledge on its own.

Memory in n8n is chat history

n8n’s own definition is short: memory “keeps a history of previous messages, allowing for an ongoing conversation with the AI.” You attach a memory sub-node to the Memory input of an AI Agent node. On every run, the node loads the recent messages for the current session and passes them to the model with the new message. Afterwards it saves the new turn.

Two settings decide what the agent sees:

  1. Session key (session ID). Every conversation gets its own key, and memory is stored and loaded under that key. With the On Chat Message trigger the sessionId usually comes along automatically. With a webhook, a form, Slack or email you set it yourself with an expression, for example the user’s ID or the thread ID.
  2. Context window length. The number of previous interactions the node sends back to the model. Older messages stay out of the prompt.

Only AI agent nodes can use memory. AI chains cannot.

Which memory node to pick

Node Where the history lives Good for Watch out
Simple Memory In the workflow data Building and testing Not safe in queue mode: calls can land on different workers
Postgres Chat Memory A table in your Postgres database (created if missing) Production, especially if you already run Postgres You manage the database and who can read it
Redis Chat Memory Redis Production, if you already run Redis Same: separation per user is up to your session keys
Zep, Xata, Motorhead The external service When you already use that service Check how it is maintained before you depend on it
Chat Memory Manager Works on top of a memory node Inserting, reading or clearing messages yourself It can overwrite memory contents, so use it carefully

n8n’s documentation lists Simple Memory, Redis Chat Memory, Postgres Chat Memory, Xata, Zep and Motorhead as memory options, and the Chat Memory Manager node for advanced cases, such as injecting messages that look like user messages to give the AI more context.

Setting it up step by step

  1. Add an AI Agent node and connect a chat model.
  2. Attach a memory node. Start with Simple Memory while you build.
  3. If you do not use the On Chat Message trigger, set the session key with an expression that is unique per conversation. For a quick test a fixed key like my_test_session works, but replace it before you publish.
  4. Set the context window length. More history gives the model more to work with, but every message costs tokens on every call.
  5. Before production, switch to Postgres or Redis Chat Memory, in particular when your instance runs in queue mode.

The common misunderstanding

Many people expect an n8n agent with memory to “remember” a customer next month or to know what a colleague’s agent learned. It does not. Chat memory is a sliding window of recent messages per session. A new session ID starts empty, and once a conversation is longer than the context window length, the earliest messages no longer reach the model. Another trap is the opposite one: n8n’s common issues page notes that if you add more than one Simple Memory node, they all access the same memory instance by default, so two agents can read each other’s history unless you give them different session IDs.

Long-term knowledge, such as customer details, decisions and how your team handles certain cases, needs a separate store the agent can search, for example a vector store or a memory service connected as a tool. The difference between those approaches is explained in What are the types of memory in AI agents? and Is RAG the same as AI memory?

What this means for a team

n8n workflows can share conversation history when configured to use shared memory. Separate workflows do not automatically share what their agents learn: the support agent in one workflow does not know what the sales agent in another learned, and neither knows what your colleagues told ChatGPT or Claude. With external memory nodes you also take on access control yourself: n8n does not separate users for you, so a badly chosen session key can show one customer’s history to another. For the bigger question of sharing memory across tools, see How can a team share one AI memory?

Where Bombos fits

n8n’s memory nodes handle the conversation; Bombos handles what should outlast it. Bombos is a plugin that gives every AI tool a team uses, including agents you build yourself, one shared memory with team knowledge, learned rules and what already sits in mail, documents and repos, and you can see what each answer rests on. It runs in our cloud or on your own server, and one person can start with it for their own agents.

Related questions

Why does my n8n agent say "No sessionId"?

The memory node cannot find a session ID. With the On Chat Message trigger it is usually picked up automatically, so check that the trigger output contains a sessionId. With any other trigger you have to set the session key yourself, for example from a user or ticket ID.

Can I use Simple Memory in production?

Not if your n8n instance runs in queue mode. n8n's documentation warns that it cannot guarantee every call to Simple Memory goes to the same worker. Use a database-backed memory node such as Postgres or Redis Chat Memory instead.

Can an AI chain in n8n use memory?

No. n8n's documentation says AI agent nodes can use memory, but AI chains cannot.

How do I give an n8n agent long-term knowledge?

Chat memory only replays recent messages. For lasting knowledge, store it in a vector store or a memory service such as Zep and give the agent a tool to search it, or connect an external memory layer.

Sources

  1. How memory works (n8n docs)
  2. Simple Memory node (n8n docs)
  3. Simple Memory node common issues (n8n docs)
  4. Postgres Chat Memory node (n8n docs)
The first half hour · free

What does your AI forget?

  1. 01You tell us which AI you use and where it keeps starting over.
  2. 02We show what a shared memory changes there, on your own examples.
  3. 03You keep the plan, with or without Bombos.
Piet Baudoin
Piet BaudoinYou talk to Piet, from the Bombos teamDutch team from Utrecht and Nijmegen · data in Europe
We reply the same working day.