Agent Memory: Short-Term, Long-Term, and User Profiles
When to remember, what to forget, and how to personalize without leaking data.
Memory layers
Production agents need three distinct memory layers with different retention policies. Session memory holds the current task context - what the user is working on right now, what tools it has called, what results it has seen. This lives for minutes to hours and resets when the task completes.
User memory stores preferences and patterns: 'This customer prefers formal tone,' 'Last time, they wanted a refund not a replacement,' 'They always CC their manager on escalations.' Retain for months, tied to the user profile. Org memory holds company-wide policies, playbooks, and learned patterns: 'We never offer discounts over 15%,' 'Escalate billing disputes to Tier 3.' Retain indefinitely, shared across all users in the organization.
Keep these stores separate with different access controls. A user should not see another user's memory. An agent should not apply one customer's org policies to another customer's. Mixing memory layers is a common source of cross-tenant data leaks.
Privacy
Memory creates privacy obligations that pure RAG systems avoid. If your agent remembers that a customer complained about a billing error, that memory is personal data under GDPR and similar regulations.
Build memory management into your product from day one: let customers view what the agent remembers about them, export their memory data, and delete it on request. Document memory retention periods in your privacy policy and DPA. Never use customer memory to train models without explicit, informed opt-in.
For enterprise customers, offer memory controls: 'Do not remember anything about executive users,' 'Auto-delete session memory after 24 hours,' 'Do not store content from legal department interactions.' These controls are increasingly required in security questionnaires.
4 more sections in this article
- When not to use memory
- Write to memory deliberately
- Retrieval and decay
- Isolation between tenants
This is Pro content
Get Agent Factory Pro - a one-time payment for lifetime access to full articles, complete build prompts, and everything new.
Use it
The parts of the library that put this article to work.
Published 27 July 2026. Last reviewed 17 August 2026. We re-read this library on a schedule and date every article, so you can see for yourself how current it is.