Crack your next interview in 2 weeks — cohort starts Jul 27 — Join free →

The Question You'll Be Asked

"How do you manage memory in an LLM application when conversations get long?"

Deliver all five beats below in under 90 seconds. Missing one signals you know the concept but haven't designed a system around it — an interviewer will probe exactly the beat you skipped.

5 Beats Interviewers Listen For

Miss one and they probe.

  1. The constraint — the context window is fixed size; history grows unbounded if unmanaged
  2. Three strategies — in-context buffer → summarisation (~4K tokens) → external retrieval (hours/multi-session)
  3. Lost in the middle — design summaries to preserve key decisions explicitly, not just compress chronologically
  4. Decision matrix — match the strategy to session length, not the fanciest option by default
  5. Cost — every extra token is money; memory design is a cost decision, not just UX

The Model Answer

"The context window is a fixed size I can't grow — everything I send must fit, and history grows unbounded if I don't manage it. I start with an in-context buffer for short sessions — zero setup. At around 4K tokens I add summarisation — one extra LLM call compresses old turns while I keep the summary verbatim. For sessions spanning hours or multiple days, I use external retrieval — vector-stored history, retrieve what's relevant per turn. Because models attend poorly to the middle of long contexts, I design summaries to preserve key decisions explicitly, not just compress chronologically. And because every extra token costs money on every call, I monitor context size and set a summarisation trigger before cost per turn crosses my unit economics threshold."

Your version doesn't have to match word-for-word — all five beats must be present.

Say This, Not That

Say

  • "Buffer, then summarisation, then external retrieval"
  • "Lost in the middle — worsens with longer context, not better"
  • "Turn 50 costs ~25× turn 2 with a raw buffer"
  • "Semantic memory persists across sessions, episodic doesn't"

Avoid

  • "Just use a bigger context window" — the #1 flagged weak answer
  • "A bigger window fixes lost-in-the-middle" (it worsens it)
  • Treating memory as a UX nicety instead of a cost decision
  • Confusing episodic memory with semantic memory