Skip to main content

Module memory

Module memory 

Source
Expand description

Memory system — 3-layer architecture.

Layer 1 — Index (always loaded): MEMORY.md contains one-line pointers to topic files. Capped at 200 lines / 25KB. Always in the system prompt.

Layer 2 — Topic files (on-demand): Individual .md files with YAML frontmatter. Loaded selectively based on relevance to the current conversation.

Layer 3 — Transcripts (never loaded, only grepped): Past session logs. Not loaded into context.

§Write discipline

  1. Write the memory file with frontmatter
  2. Update MEMORY.md index with a one-line pointer

Never dump content into the index.

Modules§

consolidation
Memory consolidation (“dreaming”).
extraction
Background memory extraction after each turn.
scanner
Memory file scanner and relevance-based selection.
session_notes
Per-session working notes.
types
Memory type system and frontmatter schema.
writer
Memory write discipline.

Structs§

MemoryContext
Persistent context loaded at session start.
MemoryFile
A single memory file with metadata.

Functions§

ensure_memory_dir
Returns the user-level memory directory, creating it if needed.
project_memory_dir
Returns the project-level memory directory (.agent/ in the project root).