
Giving Your Agents a Memory That Does Not Betray You
- AI agent memory comes in three tiers: working context, session state, and long-term memory. Each needs its own rules for what gets written, how long it lives, and how it gets deleted.
- Memory is a persistence layer for attacks. Researchers showed that poisoning under 0.1% of an agent's memory corpus produced attack success above 80%, and Microsoft reported 50 cases across 31 companies of hidden instructions writing persistent notes into assistant memory.
- Isolation has to live in the storage query, not in the system prompt. Filter by user, tenant and project first, then rank.
- Forgetting is a feature you build on purpose. Under GDPR Article 17, embeddings, summaries, caches and backups all count as places your data subject lives.
- You can test for leaks the same way you test anything else: seed two fake users, ask one about the other, and fail the build if anything crosses.
AI agent memory is what lets an agent pick up Tuesday's work on Wednesday without asking you to explain it all again, and it is also the part most likely to embarrass you in front of a customer. I have spent years watching systems get more capable and less careful at the same time. Memory is where those two trends meet. This guide covers what is worth remembering, how to keep one person's context out of another's, and how to forget on purpose.

Why Memory Makes Agents Useful and Risky
An agent without memory is a goldfish with an API key, and an agent with sloppy memory is a goldfish that talks to other goldfish. Memory is useful because it carries preferences, decisions and unfinished work across steps. It is risky for the same reason: whatever it carries can be wrong, stale, private, or planted by someone else.
It helps to separate three things people lump together under the word "memory." Working context is what sits in the model's window right now. Session state is what the system holds for the length of one conversation or task. Long-term memory is what survives across sessions. Balázs Csorba's tiered memory design makes the point that each tier needs its own write, retention and deletion policy, because the hard part is the write path, not the store.
A bigger window does not solve this. I covered why in why agents still forget: a large context window improves recall inside one session but creates no persistence at all. Persistence is a separate system you have to design, and the design is where the risk lives.
The numbers say buyers know it. Okta's enterprise buyer survey found 83% of leaders cited data leakage and 80% cited over-privileged access as barriers to adopting AI agents. Memory is where both of those worries live.

What Is Worth Remembering
Remember what changes the next decision, and let the rest evaporate. A good rule is that a memory earns its place only if forgetting it would make the agent worse at the job and remembering it would not make the agent more dangerous.
That sorts most candidates quickly. Stable preferences ("send reports as a table, not prose"), confirmed decisions, and the current state of an unfinished task all qualify. Raw transcripts, one-off complaints, and anything the user said while frustrated usually do not. Summaries of conversations deserve suspicion too, because a summary quietly turns an offhand remark into a standing fact.
Equally important is a short never-store list. Secrets, API keys, passwords and tokens belong in a vault, not in a memory file the agent reads back into its own prompt. Add payment details, health information, and anything a user explicitly asked you to keep private. Csorba suggests that every stored memory carry an owner, a source, a timestamp, a scope and an expiry date. I would add one more habit: when the agent proposes writing something to memory, make it say why. If the reason is vague, the write is probably noise.
This is the same discipline I argue for in feeding agents your documents without feeding them your secrets. What goes in is a governance decision before it is an engineering one.

Isolating One User's Context From Another's
Enforce isolation where the data is stored, because a system prompt that says "never mix users" is a polite request, not a control. Models follow instructions most of the time, and "most of the time" is not a security property.
The pattern that holds up is scope before search. Filter by user, tenant and project first, then rank by relevance. Csorba is blunt about the stakes: a cross-tenant memory leak is a data breach, and a hard filter prevents it far more reliably than a prompt does. The OWASP AI Agent Security Cheat Sheet lists the same basics: implement memory isolation between users and sessions, set memory expiration and size limits, and audit memory contents for sensitive data before persistence.
In a multi-tenant setup, separate namespaces or indexes give you a firmer boundary than one shared vector store with a tenant tag stuck on each row. If you do share a store, authorize the query before results reach the agent, not after. A filter applied after an approximate index scan can also quietly return fewer matches than you expect, so test recall under the filter and not just without it.
Isolation also has an attacker's side. Researchers reviewing long-term memory security note that AgentPoison showed a corpus-level adversary can plant backdoors with a poison rate under 0.1% and attack success over 80%. Check Point, summarizing Microsoft's findings, reports 50 cases across 31 companies where instructions hidden in links wrote persistent notes into an assistant's memory. Treat memory writes from untrusted content the way you treat user input to a database: validate first.

Forgetting on Purpose
Forgetting is a deletion pipeline, and it has to reach every place the memory was copied. Deleting the original message while leaving the embedding, the summary and last week's backup in place is the data equivalent of shredding one page of a photocopied report.
Under GDPR Article 17, a person can ask you to erase their personal data, and embeddings are part of that. The vector database analysis from Maxime M. cites research in which authors reconstructed 92% of 32-token inputs exactly from their embeddings, which is why "we only stored vectors" is a weak defense. The same piece describes erasure as a fan-out across every store that derived something from the original, which requires lineage from each derived record back to its source.
So build lineage on day one. Every summary, extracted fact and cache entry should point back to the source it came from, so a deletion request can cascade. Add expiry to episodic memory by default. Conversation snippets rarely need to outlive their usefulness by months, and a short time-to-live is the cheapest privacy feature you will ever ship.
Backups are the awkward part. You may not be able to edit a snapshot, but you can record the deletion and re-apply it when a backup is restored. Write that step into the runbook now, while nobody is panicking.

Testing AI Agent Memory for Leaks
Test memory the way an attacker would, with fake users and a list of things that must never cross. A leak you find in a test costs an afternoon. A leak a customer finds costs a contract.
Start with a canary test. Create two synthetic users, give User A a distinctive fake secret, then ask User B's session questions designed to coax it out, directly and sideways. Fail the build if the secret appears in any answer, log line or retrieved chunk. Repeat with different tenants, then with the same user across sessions after expiry, to confirm that expired means gone.
Add a poisoning test next. Feed the agent a document containing a hidden instruction to remember something false, and confirm that the write is blocked or flagged. Then add a deletion test: erase a synthetic user and search every store, including caches and the keyword index, for any trace.
None of this works without visibility into what the agent actually retrieved. That is the argument in agent observability: log what was written, what was read, and under whose scope. If you want a second pair of eyes on a memory design before it ships, book a System Review Diagnostic and we will walk through it with you.

Frequently Asked Questions
What Is Memory in an AI Agent?
Memory is any information an agent carries beyond a single model call. It usually has three tiers: working context in the prompt window, session state for one task, and long-term memory that persists across sessions. Each tier needs its own write, retention and deletion rules.
What Should an Agent Remember and Forget?
An agent should remember stable preferences, confirmed decisions and the state of unfinished work. It should forget secrets, payment and health details, offhand remarks and raw transcripts. When in doubt, ask whether forgetting would make the agent worse at the job.
How Do You Stop Agent Memory From Leaking Between Users?
Enforce isolation in the storage layer. Filter by user, tenant and project before ranking results, use separate namespaces where you can, and authorize queries before anything reaches the model. A system prompt instruction is not a security control.
How Does AI Agent Memory Work?
Most systems write selected facts to a store, such as a database, files or a vector index, and retrieve relevant ones into the prompt when needed. The model itself stays unchanged. The memory is an external system that decides what gets written and what gets read back.
Do AI Agents Remember Conversations?
Only if the system around them stores the conversation. A model alone forgets everything between calls. Products that seem to remember are saving summaries, facts or transcripts and feeding them back in, which is why deletion and retention policies matter.
References
- Okta: AI Agent Security Is Now a Priority for Enterprise Buyers
- OWASP: AI Agent Security Cheat Sheet
- arXiv: A Survey on Long-Term Memory Security in LLM Agents
- Check Point: The 7 Biggest Agentic AI Security Risks
- Balázs Csorba: Memory Design for AI Agents, Tiers and Risks
- Maxime M.: Can a Vector Database Be Agent Memory?
- Automata Intelligentsia: Context Windows Got Huge, Here's Why Your Agent Still Forgets
- Automata Intelligentsia: Feeding Agents Your Documents Without Feeding Them Your Secrets
- Automata Intelligentsia: Agent Observability, You Can't Trust What You Can't Watch
