Skip to content

Agent Memory Consolidation

Definition

Memory consolidation is a mechanism by which an agent periodically processes the contents of short-term memory (e.g., dialogue history or action results) and extracts important facts, generalizations, and lessons for storage in long-term memory.

Stages of Consolidation

  1. Collection: accumulation of records from short-term memory.
  2. Analysis: identification of key events, facts, and patterns.
  3. Generalization: creation of compressed representations.
  4. Structuring: organization into searchable entries.
  5. Storage: recording in long-term storage.
Memory Type Content Period
Short-term Current context, recent actions Session
Working Intermediate results Task
Long-term Facts, preferences, lessons Permanently

Implementation

def consolidate(short_term_memory, llm):
    facts = extract_facts(short_term_memory, llm)
    summaries = summarize_episodes(short_term_memory, llm)
    long_term_memory.add(facts)
    long_term_memory.add(summaries)
    short_term_memory.clear()

See Also