Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How to Implement Long-Term Memory for AI Companions: Pinning, Compaction, and Lessons from Mem0 and Letta

Описание и применение

В статье описывается, как реализовать долговременную память для AI‑компаньонов, используя пиннинг, сжатие и уроки из проектов Mem0 и Letta. Представлен четырёхслойный контекст, где пользователь закрепляет важные факты, а система автоматически извлекает и хранит резюме и карточки памяти.

Задача

AI companions often forget user facts when conversations exceed the model’s context window, leading to incorrect or irrelevant responses.

Результат

The four‑layer context strategy reduces memory‑related failures, ensuring user‑pinned facts are always present and that long‑term memories are accurately extracted and retrieved.

Рабочий процесс

  • 1. User pins important facts (e.g., allergies) which are stored in a pinned memory layer.
  • 2. Every turn the system injects pinned memory into the model’s context.
  • 3. Recent messages are kept in a sliding window for immediate context.
  • 4. When the conversation window closes, an extraction step creates a medium-term summary and long-term memory cards from the closed window.
  • 5. The agent retrieves relevant cards on demand based on the current query.
  • 6. Unfinished plans that span beyond the current window are promoted to cards to avoid loss during compaction.

Доказательства

The model suggests peanut butter cookies.

Источник

Mem0 keeps memory at user, session, and agent level, so the same store can hold "Alice prefers dark mode" and "this support session is about billing".

Источник

Letta answers the three questions very differently from Mem0. Memory belongs to the agent, and the agent edits it itself.

Источник

Our context for each reply has four layers: Pinned Memory, Recent messages, Medium‑term summary, Long‑term memory cards.

Источник

  • Дата записи: 2026-11-03T06:13:52.797Z