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 →
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.

Design decisions
- 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.
- Granularity: atomic facts ("prefers Python") are easier to update than long summaries. Profile documents (one per user) work well for stable attributes.
- When to write:
◦ Hot path: immediate, but adds latency and the agent may over-save.
◦ Background: better quality and no latency cost, but delayed. - Retrieval: hybrid scoring (semantic similarity + recency + importance). Always filter by user or tenant namespace.
- 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.
- Forgetting: TTLs for time-bound facts, decay, user-requested deletion ("forget X"), and compliance (GDPR right to erasure).
- 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.
Related
This is what real progress feels like.