The Problem
AI agents forget everything between sessions. Common workarounds — growing markdown files, flat vector stores, conversation logs — treat memories as a uniform blob of text. They lose the structure that matters for retrieval, aging, and relevance.
The Solution
Loci implements a four-type memory taxonomy inspired by cognitive science:
| Type | Stores | Example |
|---|---|---|
| Episodic | Events, decisions, sessions | "We deployed v2.3 on Friday" |
| Semantic | Facts, preferences, knowledge | "User prefers Rust over Go" |
| Procedural | Workflows, patterns, sequences | "How to run the deploy pipeline" |
| Entity | People, projects, systems | "Who John Smith is" |
Each type has different scoping, decay rates, and lifecycle behaviors — episodic memories fade and compact into summaries, semantic knowledge persists and strengthens with use, procedural memories version via supersession, and entities form a relationship graph.
For a deeper look at the design philosophy, see Why Loci?
Features
- Hybrid search — vector similarity (KNN) + keyword (BM25), merged with Reciprocal Rank Fusion
- Local embeddings — all-MiniLM-L6-v2 via ONNX Runtime, ~5ms per query, no API key needed
- Deduplication gate — near-duplicate memories (cosine > 0.92) are merged, not accumulated
- Confidence decay — unused memories fade; accessed memories are reinforced
- Automatic compaction — old episodic memories summarize into weekly digests
- Progressive disclosure — summary-first retrieval respects token budgets
- Entity graph — lightweight triple store for relationships between entities
- Single file storage — SQLite + FTS5 + sqlite-vec, all in
~/.loci/memory.db - Dual transport — stdio for local clients, Streamable HTTP (SSE) for remote deployment
- MCP protocol — works with Claude Code, Cowork, Agent SDK, and any MCP-compatible client
Install
Or from source:
Download the embedding model (~30MB, one-time):
Quickstart
1. Connect to Claude Code
Or add manually to your .mcp.json (project or global ~/.claude/.mcp.json):
2. Teach your agent to use memory
Add to your CLAUDE.md:
You have access to persistent memory via `loci` MCP tools. Use it proactively.
- ---
- --
When a fact changes (e.g., preference, status, version), supersede the old memory:
1. 2.
Do NOT store contradictory facts side-by-side. Always supersede the outdated one.
1. 2.3.
3. Verify
For the full setup guide, see Getting Started.
MCP Tools
| Tool | Description |
|---|---|
store_memory |
Store a new memory (with automatic deduplication) |
recall_memory |
Hybrid search by query or hydrate by ID |
forget_memory |
Soft-delete or hard-delete a memory |
memory_stats |
Counts by type, scope, DB size, timestamps |
memory_inspect |
Full details: content, metadata, relations, audit log |
store_relation |
Link two entity memories with a predicate |
For full parameter references, see the Cheatsheet.
CLI
loci serve [--transport stdio|sse] Start MCP server
loci model download Pre-download embedding model
loci model status Check model download & config status
loci search <query> Hybrid search from terminal
loci stats [--group GROUP] Memory statistics
loci inspect <id> Full memory details
loci export > backup.json Export all memories (JSON)
loci import backup.json Import memories (re-embeds)
loci compact Run maintenance (decay + compact + promote)
loci cleanup [--dry-run] Preview or delete stale memories
loci doctor Database health check + diagnostics
loci re-embed Re-embed all memories (after model change)
loci reset Delete all memories
How It Works
MCP Client (Claude Code, etc.)
↕ stdio or SSE (JSON-RPC)
Loci MCP Server
├─ 6 MCP Tools
├─ Memory Engine
│ ├─ Write: embed → dedup → store → FTS sync → vec insert → audit
│ └─ Read: embed → KNN + BM25 → RRF merge → filter → token budget
├─ Maintenance: decay → compact → promote → cleanup
├─ Storage: SQLite + FTS5 + sqlite-vec (single file)
└─ Embeddings: ONNX Runtime + all-MiniLM-L6-v2 (local, 384-dim)
For the full architecture with diagrams, see Architecture.
Configuration
Optional. Create ~/.loci/config.toml — all values have sensible defaults:
[]
= 5
= 4000
= 60
= 0.92
[]
= 0.95
= 0.99
= 30
= 0.05
= 90
Environment variable overrides:
| Variable | Overrides |
|---|---|
LOCI_DB |
Database path |
LOCI_GROUP |
Default memory group |
LOCI_LOG_LEVEL |
Log level |
Documentation
| Doc | Description |
|---|---|
| Why Loci? | Design philosophy, trade-offs, and what Loci is not |
| Getting Started | Full setup guide, MCP config, agent instructions, maintenance |
| Architecture | System diagrams, storage schema, search pipeline, module map |
| Cheatsheet | Quick reference for all tools, CLI commands, and config |
The Name
Named for the method of loci — the ancient mnemonic technique where information is stored by associating it with specific locations in a mental palace. Loci builds a structured palace for your AI agents: episodic rooms for what happened, semantic halls for what's known, procedural corridors for how things work, and entity chambers for who and what matters.
License
MIT