Inspiration Every AI coding assistant I use has the same flaw: it forgets. Close the session, and the project conventions, my naming preferences, last week's design decisions — all gone. Every new conversation starts from zero.

Meanwhile, human memory works differently: it reinforces what you use, fades what you don't, and links related facts together. I wanted AI agents to have that — not another plain vector store, and not a cloud service that ships my memory off my machine with a monthly bill.

What it does SME (Spatial Memory Engine) is a self-hosted MCP server that gives AI agents long-term, cross-session memory. Any MCP host (Claude Code, ZCode, Cursor, ...) mounts it with one line of config and gets four tools: remember, recall, reinforce, memory_stats.

[图1:hero banner]

Spatial organization — all memories live in one embedding space that self-organizes into density-driven Regions (they grow, split and merge); a six-edge semantic graph (reference / causal / conversational / summary / parent-child / neighbor) connects related memories Memory dynamics — Ebbinghaus-style reinforcement (the more a memory is used, the stronger it gets), time decay that lowers relevance but never deletes, automatic merging of duplicates, and long-term compression Interpretable retrieval — every hit ships an 8-signal score breakdown (semantic / importance / freshness / weight / decay / hit_count / recency / region), so you can audit why a memory surfaced Fully local, zero cost — runs offline with built-in hashing embeddings; for production quality it uses a local ONNX int8 Qwen3-Embedding-0.6B on CPU (7.4x faster batch embedding). Memory data never leaves the machine. How we built it [图2:architecture]

SME is a thin MCP proxy over a single-writer memory engine: the MCP process spawns on demand, talks to a local REST service, and every subprocess of the host shares one memory store (no concurrent-write corruption). Retrieval is two-stage: Region-led candidate recall, then a min-max-normalized hybrid of vector + BM25 (Chinese bigram) + metadata channels, optional Personalized PageRank graph expansion, and an 8-signal explainable ranker. Durability comes from atomic snapshots plus a WAL with grouped commits (2,557 writes/s, 1.79x). 97 documented config items, 5 presets, 190 regression tests, Apache-2.0.

Accomplishments & numbers [图3:benchmark]

In a 3-seed, 60-round, LLM-blind-judged arena against mem0 / plain RAG / BM25 / Graphiti:

96.7% accuracy (v1.3), with only 2 misled answers — fewest of all systems 2,000-distractor stress test: SME held 90% while BM25 degraded to 82.5% Long-run replay (same conversation x3): SME went 92.5% → 95% (better with use) while plain RAG went 92.5% → 87.5% [图4:gets-better-with-use]

What's new during this hackathon The project existed before the submission period; during it, it was significantly updated with Retrieval 1.3: min-max hybrid fusion (+2.5–4.2pp accuracy, retrieval bias halved), Personalized PageRank graph expansion, WAL grouped commits, and the ONNX int8 embedding pipeline. The demo video shows these updates in action.

What I learned That "memory" is not a storage problem but an evolution problem — the moment dynamics (reinforcement/decay/merge) entered the loop, long-run accuracy went up with use instead of down. Also: an 8-signal breakdown is the cheapest trust you can buy.

What's next Multi-agent shared memory sync, a VS Code extension, and English docs for a wider community.

Built With

  • ai-agents
  • embeddings
  • fastapi
  • llm
  • mcp
  • memory
  • onnx
  • python
  • rag
Share this project:

Updates

Submission history