KatInterview

Long-Term User Memory for a Personalized LLM Assistant

System DesignModel answer
MediumModel answerSystem Designllmmemoryvector-search

Last updated

Design a low-latency, scalable memory layer that lets an LLM assistant remember user facts, retrieve the relevant ones per turn, resolve conflicts, and honor deletion requests.

You are building a long-term memory layer for a conversational assistant powered by an LLM. Users casually reveal durable details over time, such as "I like dark mode" or "my dog is called Rex". On later turns, possibly weeks afterward, the assistant should use those details to give more relevant answers.

Assumptions

  • Millions of users, with many concurrent conversations.
  • Memory lookup on the response path must finish in under 100 ms.
  • Reads far outnumber writes, and writes may become visible after a short delay.

Questions to address

  1. Storage and modeling. How are facts extracted from conversations, stored, and updated? What schema would you use, and how do you weigh structured records against free-form text?
  2. Retrieval. How do you fetch only the handful of memories relevant to the current message, without scanning a user's whole history?
  3. Contradictions. A user once said "I'm vegetarian" and later says "I had steak for dinner." How should the system react to conflicting information?
  4. Scale and lifecycle. How do you keep per-user history from growing without limit? How do you support privacy obligations such as full deletion on request without hurting performance?

Expected deliverables

  • An architecture covering your storage choices (vector database, key-value cache, relational store, etc.).
  • The end-to-end flow from the user's message to the final LLM reply, including where memories are injected.
  • A method for filtering and ranking candidate memories so the prompt stays within a tight token budget.

Include rough capacity estimates and call out the trade-offs you are making.

Hints

Hint 1

Notice that every lookup is scoped to a single user. How does that change what kind of vector search you actually need compared with searching across all stored facts?

Hint 2

Separate stable traits (diet, preferred theme) from one-off events (what someone ate last night). They deserve different storage and different update rules, and an event is evidence about a trait rather than an overwrite of it.

Hint 3

Split the system into a fast synchronous read path and an asynchronous write path. Ask what happens if memory lookup is slow or down, and how you would make deletion propagate to every derived copy (vector index, cache, backups).