Understand the Memory System architecture
mainThe Memory system provides a persistent, cross-session storage layer for LLM agents to prevent information loss during context compression (autoCompact). While session memory manages continuity within a single conversation, the Memory system stores long-term knowledge that survives new sessions.
Memory Types
| Type | Purpose | Example |
|---|---|---|
user | Personal preferences | "Use tabs instead of spaces" |
feedback | How to perform tasks | "Don't mock the database" |
project | Current project state/context | "Auth rewrite is compliance-driven" |
reference | Where to find information | "Pipeline bugs are in Linear INGEST" |
Architecture Components
- Storage: Markdown files in a
.memory/directory, each with YAML frontmatter (name,description,type). - Index: A
MEMORY.mdfile acting as a catalog for the SYSTEM prompt. - Loading: Uses a two-path approach: a permanent index in the SYSTEM prompt and on-demand injection of relevant file contents via LLM side-queries.
- Extraction: A 'forked agent' extracts new memories from dialogue at the end of a turn when the model stops without using tools.
- Consolidation (Dream): A periodic process that deduplicates, merges, and removes outdated memories when a threshold (e.g., 10 files) is reached.