# Memory for Chats — AI Automation with n8n

Source: https://www.geekswithgeeks.com/en/n8n-ai-automation/tools-memory

> Add window memory so a chat keeps context, and understand its limits.

## The model remembers nothing by itself

Each model call is independent, so a chat "remembers" only because earlier messages are sent again. A **Window Buffer Memory** sub-node stores the last N messages per **session ID** and adds them to each call. Use a different session ID per user or conversation, or people will see each other's history. In-process memory is lost on restart, so use a persistent memory node (for example a database-backed one) for production.

## Session IDs per user

Take the session ID from something stable and private, such as a user ID from your system, not from text the user can edit.

```text
Window Buffer Memory
  Session ID : {{ $json.userId }}        (not a shared constant!)
  Window size: 10 messages
```

**Quiz:** What happens if all users share one memory session ID?

- [ ] Nothing changes
- [ ] The model gets smarter
- [x] Users see and mix each other's conversation history
- [ ] n8n crashes immediately

*Answer:* Users see and mix each other's conversation history. Memory is keyed by session ID, so a shared ID leaks context between users.
