Skip to main content

Module extraction

Module extraction 

Source
Expand description

Background memory extraction after each turn.

At the end of each successful query loop (model responds with no more tool calls), a background task analyzes recent messages and saves relevant memories. This is fire-and-forget — failures are logged but never shown to the user.

The extraction agent:

  • Reads the last N messages for extractable knowledge
  • Checks existing memories to avoid duplicates
  • Writes new memory files with proper frontmatter
  • Updates the MEMORY.md index

Mutual exclusion: if the main agent already wrote to memory files during this turn, extraction is skipped.

Structs§

ExtractionState
Tracks extraction state across turns.

Functions§

build_memory_manifest_public
Build a manifest of existing memory files with content previews. This lets the LLM check for duplicates and decide whether to update existing files or create new ones. Public access to the memory manifest for consolidation.
extract_memories_background
Run memory extraction as a background task.