Skip to main content

Pattern · Agents

Short- and long-term memory

Keep the current conversation compact, and save durable facts about the user across sessions with source and date.

Say it in the interview

I would summarise old turns to keep the thread small, and have a background job save durable facts per user with source and date, always filtered by user id, visible and deletable by the user.

When to use it

  • Assistants people return to
  • Long conversations that overflow the context

How it works

  1. Current thread → Summary of old turns + last turns in full
  2. Summary of old turns + last turns in full → Model call
  3. Finished task → background job extracts facts → Long-term store (per user, with source and date)
  4. Long-term store (per user, with source and date) → read relevant facts → Model call

Trade-offs

  • Personal and consistent
  • Privacy duties: users must see and delete what is stored

Pitfalls interviewers probe

  • Saving everything
  • Facts with no date, so stale ones never expire
  • Reading memory across users

Practise it on these questions

Today's AI turns are used

Lessons, roadmaps, videos, practice cards and the code playground stay free with your account, with no limit.