A language model has no memory of its own. Whatever it appears to remember is information you put back into its context. Designing memory means deciding what to store, where and when to retrieve it.
Three layers
- Working context: the current conversation, instructions and tool results inside the context window. Fast but limited.
- Session state: structured data for this task: user ID, order number, steps completed. Store it in your application, not in the prompt text.
- Long-term memory: facts and history kept across sessions in a database or vector store and retrieved when relevant. See RAG.
Design choices
- What to remember: preferences, past tickets, outcomes. Avoid storing sensitive data you do not need.
- How to summarise: long histories should be condensed so context stays focused.
- When to forget: set retention limits and a deletion path.
- How to retrieve: by user, topic and recency, with permission checks.
Privacy and compliance
Memory often holds personal data. Apply purpose limits, retention and deletion; see DPDP and AI and GDPR and LLMs.
Common mistakes
Dumping full transcripts into every prompt, mixing users' memories, and keeping data forever.
Frequently asked questions
Do AI agents have memory?
Not natively. Memory is built by storing information in your application or a database and supplying relevant parts back to the model on each call.
What is the difference between context and memory?
Context is what the model sees in a single call. Memory is stored information you retrieve and place into context when needed.
How do I stop an agent leaking one user's memory to another?
Scope every memory read and write by user or tenant and enforce permission checks in the retrieval layer, not in the prompt.
Related: AI agent development · RAG development · DPDP and AI
Want a straight answer for your project?
Book a 30-minute call. I will tell you what I would do, and a fixed price if it makes sense.