Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
51 small wins to finish your pathNext question →

Q29IntermediateConcept

Design long-term memory for an agent: what to store, when to write, how to retrieve, and how to forget.

30-second answerSay your answer out loud first, then reveal.
Long-term memory: an extractor LLM turns the conversation into candidate facts, which are reconciled against existing memories to add, update, delete or ignore; a new query retrieves from the memory store by semantic similarity, recency and importance, and the result is injected into context.

Design decisions

  1. What to store: stable preferences, facts about entities, important decisions, outcomes of past tasks, and procedural lessons ("deploy needs VPN first"). Not small talk or secrets.
  2. Granularity: atomic facts ("prefers Python") are easier to update than long summaries. Profile documents (one per user) work well for stable attributes.
  3. When to write:
    ◦ Hot path: immediate, but adds latency and the agent may over-save.
    ◦ Background: better quality and no latency cost, but delayed.
  4. Retrieval: hybrid scoring (semantic similarity + recency + importance). Always filter by user or tenant namespace.
  5. Conflict resolution: "moved from Delhi to Bangalore" must update, not add a contradicting fact. Tools such as Mem0 and LangMem implement add/update/delete reconciliation.
  6. Forgetting: TTLs for time-bound facts, decay, user-requested deletion ("forget X"), and compliance (GDPR right to erasure).
  7. Privacy: don't store sensitive categories without consent; encrypt; audit.

Evaluation: test whether the agent recalls the right fact, doesn't surface stale facts, and doesn't leak one user's memory to another.

This is what real progress feels like.