Design memory that persists across sessions for an assistant. How is it different from managing context within a session?
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Within a session you are compressing a transcript you already have. Across sessions you are deciding what was ever worth keeping, and that is a data problem with an ugly lifecycle.
Full worked answer
Within a session you are compressing a transcript you already have. Across sessions you are deciding what was ever worth keeping, and that is a data problem with an ugly lifecycle.
What to write. Not transcripts. Durable facts, stated preferences, decisions, and entities. An extraction step at session end (or on an explicit trigger) that emits typed records: {type, key, value, source_turn, timestamp, confidence}. Typed records are inspectable, diffable, and deletable. A pile of summarised prose is none of those.
What to read. Not everything. A small always-on profile block plus relevance-retrieved records for this turn. Loading all memory reintroduces exactly the bloat you built memory to avoid.
Updates are the hard part, and it is where most designs fail. Memory goes stale. "Lives in Berlin" was true and now is not. Append-only stores end up holding both facts, retrieval returns both, and the model picks one at random. You need supersede semantics: write by key, mark old records superseded, keep the history for audit but retrieve only the live value. Contradictory memories are worse than no memory, because they produce confident inconsistency that users read as the system being broken.
The failure modes to name:
- Poisoning. A wrong fact gets written once and then repeated forever, and because the model keeps restating it, it can get re-extracted and reinforced. There is no natural decay unless you build one.
- Injection. Content the user pasted becomes a "memory", and later that memory is rendered into context where it reads as an instruction. Memory must always be rendered as data, never as instructions, and must never be able to grant capability.
- Privacy. Memory crosses sessions and, if you get it wrong, users or tenants. Isolation is non-negotiable, and the deletion path has to actually delete, including from any index.
Controls that make it shippable: user-visible and user-editable memory, provenance on every record, and TTLs on things that expire.
Evaluate both directions: does memory raise task success, and how often does it inject something wrong? Teams measure the first only.
What a good answer covers
- Within a session you are compressing a transcript you already have
- Across sessions you are deciding what was ever worth keeping, and that is a data problem with an ugly…
- Durable facts, stated preferences, decisions, and entities
- An extraction step at session end (or on an explicit trigger) that emits typed records
- Typed records are inspectable, diffable, and deletable
Key terms: What to write · What to read · The failure modes to name · Poisoning · Injection · Privacy · Controls that make it shippable · Evaluate both directions
Interviewer follow-ups to expect
How would you detect memory poisoning in production?
- Poisoning. A wrong fact gets written once and then repeated forever, and because the model keeps restating it, it can get re-extracted and reinforced. There is no natural decay unless you build one.
- Injection. Content the user pasted becomes a "memory", and later that memory is rendered into context where it reads as an instruction. Memory must always be rendered as data, never as instructions, and must never be able to grant capability.
- Privacy. Memory crosses sessions and, if you get it wrong, users or tenants. Isolation is non-negotiable, and the deletion path has to actually delete, including from any index.
What is your policy when a retrieved memory contradicts what the user just said in this turn?
Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep