Skip to content

Long-term memory ingests full history every turn and stores chit-chat #67

@SamariddinS

Description

@SamariddinS

Problem

MemoryService.add() is invoked at the end of every chat turn with the
entire LangGraph message history (response["messages"] /
state.values["messages"]). Two failure modes stack:

  1. Repeated re-extraction. Mem0's fact extractor runs against every
    prior turn on every call, so the same messages are paid for N times
    and near-duplicate rows slip past dedup into pgvector.
  2. Permissive default prompt. Mem0's out-of-the-box extractor
    captures greetings, acknowledgements, transient task instructions,
    and assistant chit-chat — exactly the noise we don't want persisted.

Result: longterm_memory fills with rows like "2 + 2",
"Assistant offered to help", duplicate restatements of the same
preference, etc. Memory search quality degrades, token spend on the
extractor grows linearly with session length.

Reproduction

  1. Start a session, send "what is the sum of 2 + 2" → a memory row is written "Asked how much is 2 + 2".
  2. Send any follow-up → the extractor re-processes the sum plus
    the new turn; more near-duplicate rows land in pgvector.
  3. Inspect longterm_memory rows for the user — pointless entries
    dominate the legitimate facts.

Impact

  • Polluted long-term memory → worse retrieval relevance on
    memory_service.search.
  • Unnecessary LLM spend on LONG_TERM_MEMORY_MODEL (extractor re-runs
    the full history).
  • Cost scales O(turns²) over a session instead of O(turns).

Proposed fix in PR #66

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions