A language model has no memory. Every request is independent, and everything it appears to remember was sent to it in that request. Building an assistant that usefully remembers things is therefore an application design problem, and it is one that gets harder — not easier — as the system remembers more.
Three kinds of memory
Working memory is the current conversation. Bounded by the context window, discarded when the session ends. Everything in it is available at full fidelity.
Durable facts are things worth carrying across sessions: the user's role, their timezone, the project they are working on, a stated preference. Small, structured, high value.
Retrieved memory is a searchable archive of past interactions — surfaced when relevant, ignored otherwise. Unbounded in size, accessed by query rather than carried.
Most implementations conflate the second and third, which is where the trouble starts. Durable facts should be few, structured and always present. Past conversations should be many, unstructured and retrieved on demand.
Managing working memory
A long conversation eventually exceeds the window, and dropping the oldest messages loses the constraints established at the start — which are usually the most important ones.
[ system prompt ] always
[ pinned facts ] always — extracted, structured, small
[ rolling summary ] older turns, compressed
[ last N turns verbatim ] recent detail preserved
[ current message ]
The rolling summary should be structured rather than prose:
{
"decisions": ["Using PostgreSQL, not MySQL", "Deadline is 12 September"],
"constraints": ["No third-party analytics", "Must support IE11"],
"established": ["The client is in Berlin", "Budget approved at £40k"],
"open": ["Which payment provider?"]
}
A structured summary survives repeated compression far better than a paragraph, which degrades a little each time it is rewritten until the original constraint has quietly vanished.
Extracting durable facts
Deciding what to persist is the interesting part. Two approaches, and the second is usually better:
- Model-extracted — after each session, ask a model what is worth remembering. Flexible, and it will confidently store things that are wrong or transient.
- Schema-constrained — define the fields you are willing to remember and extract only those. Less magical, far more predictable, and it makes the privacy story explainable.
{
"role": "engineering manager",
"timezone": "Europe/Berlin",
"current_project": "billing-migration",
"preferences": { "response_length": "concise", "code_style": "psr-12" },
"do_not_suggest": ["mongodb"]
}
A closed schema means you can show the user exactly what is stored, let them edit it, and delete it cleanly — none of which is practical with a free-form pile of model-written notes.
The staleness problem
This is the failure mode people underestimate. A user says "I'm working on the billing migration" in March. In August the assistant still opens with billing migration context, because nothing ever expired it.
Mitigations that work:
- Timestamp every fact, and include the age in the prompt: "current_project: billing-migration (recorded 5 months ago)". The model then treats it as a possibly-stale hint rather than a fact.
- Give facts a natural TTL by category. Timezone is durable; current task is not.
- Update rather than append. A new statement about the same field replaces the old one. Storing both produces contradictory context and unpredictable behaviour.
- Confirm occasionally. "Still working on the billing migration?" is cheap and keeps the store accurate.
Contradictions are the specific thing to design against. If memory contains both "prefers Python" and "prefers Go", the model will pick one arbitrarily and the user will experience the assistant as unreliable.
Retrieved memory
For past conversations, treat it as a retrieval problem rather than a context problem: embed and index summaries of past sessions, retrieve when relevant to the current query, and never carry them by default.
{
"session_id": "...",
"date": "2026-06-12",
"summary": "Debugged a slow invoice query. Root cause was a missing
composite index on (tenant_id, issued_at). Resolved.",
"entities": ["invoices", "postgres", "indexing"],
"outcome": "resolved"
}
Index the summary, not the transcript. A raw transcript retrieves badly — it is mostly conversational filler — and it is much larger to store and to send.
Weight recency alongside similarity. A six-month-old session about the same topic is usually less relevant than last week's, and pure vector similarity has no notion of that.
Privacy and control
Memory turns an ephemeral tool into a personal data store, with obligations attached:
- Make it visible. Users should be able to see everything remembered about them, in plain language. A closed schema makes this trivial and free-form notes make it nearly impossible.
- Make it editable and deletable, per item and in bulk. Under GDPR this is a right, not a feature.
- Offer a session with no memory. Some conversations should leave no trace, and users will not trust a system that never forgets.
- Scope it correctly. Memory is per user, and in a shared workspace the boundary between personal and team memory must be explicit. Leaking one colleague's context into another's session is a serious failure.
- Do not remember what you should not store. Health details, financial details and credentials mentioned in passing should be excluded by the extraction schema rather than captured and then protected.
- Retention limits, enforced by a scheduled job rather than a policy document.
Start smaller than you think
The temptation is to build an elaborate memory architecture up front. In practice a handful of structured fields plus retrieval over session summaries covers the large majority of the value, and it is comprehensible enough to debug when it behaves oddly.
Watch what users actually repeat themselves about — that is the evidence for what is worth remembering. Everything else is complexity you added on speculation, and memory is one of the few areas where being wrong is not just useless but actively degrades the product.
Related Service
🤖 Business Process Automation
Business process automation with n8n, Zapier, Make, and AI — connect your tools, eliminate repetitive work, and let workflows run themselves around the clock.
Explore Business Process Automation →
Reviews & Comments
Reviews are moderated and appear after approval.
No reviews yet — be the first to share your thoughts.
Leave a Review