DEV Community

golflover
golflover

Posted on

MeshCtx Memory Engine v2: FSRS Spaced Repetition for AI Agents

The Problem

Most AI agents forget everything between sessions. We built MeshCtx to solve this with a persistent memory system that actually learns and consolidates knowledge over time.

Memory Engine v2

The key innovation is combining three techniques:

1. FSRS Spaced Repetition

Instead of storing all memories equally, we use Free Spaced Repetition Scheduler (FSRS) to prioritize what to review. Memories that haven't been accessed decay naturally, while frequently-used knowledge gets reinforced.

2. Three-Layer Schema Consolidation

Memories flow through three layers:

  • Episodic: Raw event memories (what happened)
  • Semantic: Consolidated knowledge (what it means)
  • Core: Fundamental patterns and preferences

The consolidation happens automatically during "sleep phases" - offline periods where the agent reviews and reorganizes memories.

3. ARCHIVAL Pruning

Old memories are archived (not deleted) using a recoverable pruning strategy. This keeps the active memory compact while preserving everything for potential retrieval.

Benchmark Results

Tested on LongMemEval benchmark:

  • 54.2% Exact Match (vs GPT-4o no-memory baseline 60-64%)
  • 83.3% Semantic Judge Score
  • Tool output compression: 5008B → 223B (-95.5%)

Try It

git clone https://github.com/LucyAndLuna2023/meshctx
cd meshctx
pip install -r requirements.txt
python -m meshctx.server
Enter fullscreen mode Exit fullscreen mode

Contributing

We're looking for contributors! Areas where help is needed:

  • Additional memory consolidation strategies
  • Integration with other LLM providers
  • Performance optimization for large memory stores

Open an issue or PR on GitHub.

Top comments (0)