Skip to main content

Module consolidation

Module consolidation 

Source
Expand description

Memory consolidation (“dreaming”).

Background process that reviews memory files and consolidates them: merging duplicates, resolving contradictions, converting relative dates to absolute, pruning stale entries, and keeping the index under limits.

Uses a lock file to prevent concurrent consolidation across multiple agent sessions.

Functions§

build_consolidation_prompt
Build the consolidation prompt for the dream agent.
release_lock
Release the consolidation lock by updating its mtime to now. This marks the consolidation as complete (mtime = last consolidated time).
rollback_lock
Roll back the lock on failure (rewind mtime so next session retries).
run_consolidation
Run the full consolidation pipeline via LLM.
should_consolidate
Check if consolidation should run.
try_acquire_lock
Try to acquire the consolidation lock. Returns the lock path if acquired, None if another process holds it.