10. Memory
How AI applications remember. Statelessness, conversation history, summarisation, long-term memory, semantic memory, retrieval of memories, consent, retention and privacy.
Models are stateless
An LLM remembers nothing between API calls. A chatbot that “remembers” what you said is an application that re-sends the relevant history with every request. Memory is therefore an application design problem: what to store, what to put back into the context, for how long, and with whose permission.
Kinds of memory
| Kind | Analogy | Holds | Typical implementation |
|---|---|---|---|
| Working memory | What you are thinking now | The current context window | The prompt itself |
| Short-term (conversation) memory | The conversation so far | Recent turns of this conversation | Stored turns keyed by conversation ID; last N within a budget |
| Long-term memory | Things you know about a person | Facts, preferences, past decisions across conversations | A memory store searched by relevance and recency |
| Episodic memory | Remembering what happened | Records of past runs or episodes | Logs, traces, summaries |
| Semantic / knowledge memory | General knowledge | Documents, manuals | RAG over a corpus (chapter 5) |
| Procedural memory | Knowing how | Instructions, skills, tools | System prompts, tool definitions |
Conversation memory
The simplest approach sends the last N turns. Because context is finite and costs money:
- Window: keep the last N messages within a character or token budget, dropping the oldest.
- Summarisation: replace older turns with a running summary.
- Retrieval over history: embed past turns and retrieve the relevant ones.
Follow-up questions (and what about managers?) depend on history; in RAG, use history to rewrite the question before retrieval (chapter 6).
Long-term memory
Long-term memory stores individual facts (prefers vegetarian meals, works in the Berlin office) and recalls the relevant ones in later conversations. Design questions:
- What to store? Only what is useful later. Let the model decide via a save memory tool, with rules.
- How to recall? By keyword match, by embedding similarity (semantic recall), by recency, or a mix. Small per-user memory sets benefit from recency fill, because keyword overlap misses paraphrases.
- How to organise? Namespaces per user (or per tenant) so one person’s memories never reach another.
- When to forget? Retention periods per entry; deletion on request.
Consent and privacy
Memory is personal data. Good practice:
- Explicit consent before storing personal facts, enforced by the system, not merely requested in the prompt.
- Transparency: users can see what is remembered.
- Deletion: users can delete any memory, and everything is deleted with the project or account.
- Retention: memories expire by default.
- Never store secrets (passwords, keys); scan or instruct against it.
- Isolation: strict per-user namespaces.
Memory vs RAG
Both put information into the context. RAG retrieves from a shared corpus you curate; memory retrieves per-user facts gathered from interactions. Many assistants use both: RAG for the handbook, memory for the person asking.
Try it in AgenticMind
| Need | Node |
|---|---|
| Load recent turns | Conversation History (max_turns, max_chars) → Agent history |
| Store a turn | Save Conversation Turn (retention_days, 30 by default) |
| Store a fact with consent | Remember (consent input required) or Memory Tool in save mode |
| Recall facts | Recall or Memory Tool in recall mode (keyword then recency) |
Template Assistant with memory; the Chat toggle Remember facts I share is the consent input, off by default; the Memory tab shows and deletes everything. See Memory.
Key takeaways
Models are stateless; memory is what the application chooses to re-send. Keep short-term conversation state separate from long-term facts. Recall by relevance and recency within a budget. Treat memory as personal data: explicit consent, visibility, retention, deletion and per-user isolation.

