Sleep Consolidation
Mnemosyne's background process that promotes aged Working Memory entries to Episodic Memory, inspired by human sleep's role in memory consolidation.
What Sleep Does
During each consolidation cycle, Mnemosyne:
- Scans Working Memory for entries older than TTL/2 (12 hours by default)
- Groups candidates by
source - Summarizes each group via local LLM (TinyLlama) or AAAK text substitution
- Promotes summaries to Episodic Memory (with
summary_oftracking originals) - Evicts original Working Memory entries
Trigger Conditions
Consolidation triggers on:
- Age threshold: When Working Memory entries exceed TTL/2 (default: 12 hours with 24h TTL)
- Explicit call:
mem.sleep()ormem.consolidate()for manual consolidation - auto_sleep: Background thread that periodically runs consolidation without explicit calls (configure via
config.yamlorMNEMOSYNE_AUTO_SLEEPenv var) - Shutdown: Graceful process exit
Consolidation Pipeline
flowchart LR A[Working Memory] -->|age > TTL/2| B[Candidate Selection] B -->|group by source| C[Group Entries] C -->|summarize| D[LLM or AAAK] D -->|promote| E[Episodic Memory] C -->|evict originals| F[Delete from Working]
Step-by-Step
- Candidate selection: Find all Working Memory entries where
created_at < now - TTL/2 - Group by source: Cluster candidates by their
sourcefield - Summarize: For each group, generate a summary using:
- Local LLM (TinyLlama) if available
- AAAK
encode()text substitution as fallback
- Promote: Insert summary into
episodic_memorywithsummary_ofreferencing the original IDs - Evict: Delete the original entries from
working_memory - Log: Record the consolidation in
consolidation_log
Retention Values
| Parameter | Default | Description |
|---|---|---|
MNEMOSYNE_WM_MAX | 10000 | Maximum Working Memory entries |
| TTL | 24h | Time-to-live for Working Memory entries |
Monitoring Consolidation
Consolidation events are logged to the consolidation_log table:
| Column | Type | Description |
|---|---|---|
id | INTEGER | Auto-increment primary key |
session_id | TEXT | Session that was consolidated |
items_consolidated | INTEGER | Number of entries promoted |
summary_preview | TEXT | Preview of the generated summary |
created_at | TIMESTAMP | When consolidation ran |
Performance Impact
Sleep consolidation runs in a background thread and does not block agent operations. On typical hardware, a full cycle processes ~1000 entries in under 5 seconds.
Related Pages
BEAM Architecture
Overview of BEAM (Biological-inspired Episodic-Associative Memory), Mnemosyne's four-tier architectu...
Episodic Memory
Learn about Episodic Memory in Mnemosyne: time-stamped sequences of events and experiences that let ...
Cron Jobs
Configure cron jobs for Mnemosyne: scheduled memory consolidation, cleanup tasks, backup routines, a...
Mnemosyne