Skip to content

LLM driven memory consolidation #34

@nambok

Description

@nambok

Problem

Memory consolidation currently uses rule based sentence deduplication. This misses semantic duplicates ("uses Rust" vs "prefers Rust for systems work") and cant intelligently decide whether a new fact should ADD a new memory, UPDATE an existing one, or DELETE an outdated one.

Proposed Solution

Use the existing LLM extraction pipeline for consolidation decisions:

Consolidation operations

  • ADD — genuinely new information, store as new memory
  • UPDATE — refines or supersedes an existing memory, merge them
  • DELETE — explicitly contradicted or retracted, mark as invalid
  • MERGE — two existing memories say the same thing differently, combine into one

Implementation

  1. When new memories are extracted, retrieve the top-K most similar existing memories
  2. Send the new + existing memories to the LLM with a consolidation prompt
  3. LLM returns the operation (ADD/UPDATE/DELETE/MERGE) with the resulting memory text
  4. Apply the operation to the graph

Constraints

  • Consolidation should be async (dont block process_turn)
  • Batch consolidation for efficiency (collect candidates, process in bulk)
  • Keep an audit log of consolidation decisions for debugging
  • Fallback to current rule based approach if LLM is unavailable

Why

Rule based dedup catches exact and near exact duplicates but misses everything else. LLM consolidation enables the memory system to reason about what it knows, producing a cleaner, more accurate memory graph over time.

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