Alaya
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
The only memory engine with neuroscience-grounded memory dynamics — Bjork dual-strength forgetting, retrieval-induced suppression, and Hebbian co-activation — in a zero-dependency embeddable Rust library.
**Alaya** (Sanskrit: *alaya-vijnana*, "storehouse consciousness") is an
embeddable Rust library. One SQLite file. No external services. Your agent
stores conversations, retrieves what matters, and lets the rest fade. The
graph reshapes through use, like biological memory.
The Problem
Most AI agents treat memory as flat files. OpenClaw writes to MEMORY.md.
Claudesidian writes to Obsidian. Hand-rolled systems write to JSON or
Markdown. It works at first.
Then the files grow. Context windows fill. The agent dumps everything into
the prompt and hopes the LLM finds what matters.
**The cost is measurable.** OpenClaw injects ~35,600 tokens of workspace
files into every message, 93.5% of which is irrelevant
(#9157). Heavy users
report $3,600/month
in token costs. Community tools like
QMD and
memsearch cut 70-96% of that
waste by replacing full-context injection with ranked retrieval
(Levine, 2026).
**The structure problem compounds the cost.** MEMORY.md conflates decisions,
preferences, and knowledge into one unstructured blob. Users independently
invent decision.md
files, working-context.md snapshots, and
12-layer memory architectures
to compensate. Monday you mention "Alice manages the auth team." Wednesday
you ask "who handles auth permissions?" The agent retrieves both memories
by text similarity but cannot connect them
(Chawla, 2026).
How Alaya Solves It
| Problem | File-based memory | Alaya |
|---|---|---|
| **Token waste** | Full-context injection (~35K tokens/message) | Ranked retrieval returns only top-k relevant memories |
| **No structure** | Everything in one file (users invent decision.md workarounds) | Three typed stores: episodes, knowledge, preferences |
| **No forgetting** | Files grow until you manually curate | Bjork dual-strength decay separates storage strength from retrieval strength; retrieval-induced forgetting (RIF) actively suppresses competing memories |
| **No associations** | Flat files, no links between memories | Hebbian co-retrieval strengthening (LTP/LTD): memories retrieved together strengthen connections; spreading activation finds indirect associations |
| **Brittle preferences** | Agent-authored summary, easily drifts | Implicit preferences emerge from accumulated impressions via vasana (perfuming), no LLM required; crystallize at threshold |
| **LLM required** | Can't function without one | Graceful degradation at every level. No embeddings? BM25-only. No LLM? Episodes accumulate. Each capability independently optional |
Getting Started
MCP Server (recommended for agents)
The fastest way to add Alaya memory to any MCP-compatible agent (Claude Desktop,
Claude Code, Cursor, Cline, etc.):
Via npm (no Rust toolchain needed)
Add to your Claude Code config (~/.claude/claude_code_config.json):
Or for Claude Desktop / other MCP clients (with optional LLM auto-consolidation):
From source (requires Rust 1.75+)
Then add to your MCP config:
The ALAYA_LLM_* env vars are optional — without them, the server works in
prompt mode (reminds the agent to call learn after 10 episodes). With an API
key and the llm feature, it auto-consolidates instead.
That's it. Your agent now has 13 memory tools:
| Tool | What it does |
|------|-------------|
| remember | Store a conversation message (auto-prompts consolidation after 10 episodes) |
| recall | Search memory with hybrid retrieval (+ category boost) |
| learn | Teach extracted knowledge directly — agent extracts facts and calls this |
| status | Rich memory statistics: episodes, knowledge breakdown, categories, graph, embeddings |
| preferences | Get learned user preferences |
| knowledge | Get distilled semantic facts (+ category filter) |
| maintain | Run memory cleanup (dedup, decay) |
| purge | Delete memories by session, age, or all |