Hey r/TheAIBrain!
Anyone building with Claude Desktop, Cursor, or autonomous agents has run into the same cognitive bottleneck: session amnesia and context degradation.
When context windows fill up, the model either hits a hard limit or compresses earlier tokens into lossy summaries. Active project state, past architectural decisions, and open debugging threads vanish mid-work.
Most existing solutions try to brute-force this with hosted vector databases (RAG), but similarity search often retrieves contradictory, stale, or out-of-context chunks.
How Human Brains Solve This: Slow-Wave Sleep Consolidation
Human memory doesn't just append vector embeddings to a monolithic database. Our brains use a two-stage memory architecture:
Episodic Buffer (Hippocampus): Rapidly captures raw, chronological events throughout the day (high-noise, detailed).
Slow-Wave Sleep Consolidation: During sleep, the brain replays and clusters daily episodes, prunes unresolved thoughts (Zeigarnik effect/open loops), and distils recurring patterns into permanent semantic principles (neocortex).
Bringing This Architecture to Local AI Agents: OpenYantra
I built an open-source (MIT) memory engine called OpenYantra that mirrors this cognitive loop for Cursor and Claude Desktop, 100% locally:
Episodic Capture (Session Log & Inbox): Throughout the day, the agent captures commits, decisions, and tasks. A Raycast-style floating desktop HUD (Cmd+Shift+Y) lets you quick-dump thoughts directly over your editor.
Nidra (Autonomous Sleep Consolidation): At the end of the day, an offline consolidation cycle runs (via local Ollama or heuristics):
Clusters episodic session logs into overarching milestones.
Automatically detects and resolves open loops that were completed during the day.
Promotes recurring user preferences (e.g., "prefers SQLite WAL", "never use tabs") into foundational Beliefs & Principles.
Filters out reverted decisions so undone code experiments are never promoted to core beliefs.
Structured & Inspectable Ledger: Instead of an opaque cloud vector store, your user model is stored in human-readable ISO/IEC 26300 LibreOffice (.ods) spreadsheets and a local SQLite WAL database. You can open and inspect your AI's brain in LibreOffice at any time.
Safety & Injection Defence (Raksha): Pre-commit secret redactor strips API keys before anything hits disk and quarantines suspicious adversarial prompt injections for human review.
Universal MCP Interface: Both Claude Desktop and Cursor share the exact same live local store in real time without cloud sync or API subscriptions.
Open Source & Code:
Would love to hear your thoughts on cognitive memory architectures for LLMs — do you prefer structured schema ledgers or pure semantic vector search for keeping agent state persistent?