SideGuy SolutionsText PJ
n8n AI Agent Memory

n8n AI Agent Simple Memory needs a stable session ID.

If your n8n AI Agent forgets context, repeats itself, or mixes conversations, the first place to check is the Simple Memory session ID. Memory only works if the same conversation keeps the same key.

Short answer: set the n8n Simple Memory session ID to a stable per-user or per-thread value. Use the chat ID, customer ID, email hash, or incoming thread ID. Do not use a fresh random value on each run, and do not reuse one global value for everyone.

The simple rule

Simple Memory stores history by session ID. Same session ID means same conversation memory. New session ID means a blank memory bucket. Shared session ID means shared context, which is usually dangerous.

Good:
sessionId = {{$json.chat_id}}
sessionId = {{$json.customer_id}}
sessionId = {{$json.thread_id}}

Bad:
sessionId = {{$now}}
sessionId = {{$random()}}
sessionId = "default"

Where the session ID should come from

  • Chat apps: use the chat ID, conversation ID, or channel plus user ID.
  • Web forms: use a customer ID, submitted email hash, or generated lead ID that persists.
  • Support inboxes: use the ticket ID or email thread ID.
  • Internal tools: use the operator's user ID plus the case, account, or workflow ID.

Common failure modes

Forgets everythingThe session ID is changing every execution. Fix it by mapping to a stable incoming field.
Mixes usersEveryone is sharing the same session ID. Fix it by adding a per-user or per-thread key.
Works in test, fails liveYour test data has a field that production does not. Add fallback handling before memory.
Too much stale contextThe session is too broad. Use a case or thread ID instead of a whole-company ID.

Operator-honest setup pattern

  1. Find the most stable incoming identifier.
  2. Normalize it before the AI Agent runs.
  3. Pass that value into Simple Memory as the session ID.
  4. Log the session ID in test runs so you can see when it changes.
  5. Use separate IDs for separate users, customers, or threads.

Want PJ to sanity-check your n8n workflow?

Send the workflow shape, the trigger source, and what field you are using as the session ID. PJ can tell you whether memory will persist, reset, or leak.

Text PJ the trigger
Text PJ