Bio-inspired persistent memory for AI agents. 5-layer architecture with FTS5, vector search, knowledge graph, and HybridRAG fusion.
Project description
๐ง Rewind Memory
Bio-inspired persistent memory for AI agents.
Rewind gives AI agents structured, persistent memory that works like biological memory โ keyword search, knowledge graphs, semantic vectors, score fusion, and intelligent retrieval. Every memory is classified by type (user, feedback, project, reference), weighted by recency, and checked for drift. Runs fully local on SQLite with zero third-party dependencies.
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ L2 Orchestrator โ
โ (fusion ยท ranking ยท deduplication) โ
โโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโฌโโโโโโโโโโโค
โ L0 โ L1 โ L3 โ L4 โ
โSensory โ System โ Graph โ Vector โ
โ Buffer โ Files โ โ Search โ
โ โ โ โ โ
โ SQLite โ File โ SQLite โsqlite-vecโ
โ FTS5 โ system โ Graph โ (vec0) โ
โโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโดโโโโโโโโโโโ
Layers
| Layer | Name | Bio Analogy | Backend | Purpose |
|---|---|---|---|---|
| L0 | Sensory Buffer | Sensory cortex | SQLite FTS5 | Fast keyword search, BM25 ranking |
| L1 | System Memory | Working memory | File system | Identity, preferences, context โ loaded every session |
| L2 | Orchestrator | Prefrontal cortex | In-process | Fuses keyword + graph + vector results |
| L3 | Knowledge Graph | Association cortex | SQLite | Entity relationships, spreading activation, Hebbian learning |
| L4 | Vector Search | Episodic memory | sqlite-vec | Semantic similarity via local embeddings (Ollama) |
Quick Start
pip install rewind-memory
rewind doctor # Auto-diagnose and fix memory stack
rewind ingest-chats # Backfill historical OpenClaw conversations
rewind watch # Real-time conversation indexing (L0 keyword search)
rewind search "what did we discuss about X"
Full walkthrough: docs/QUICKSTART.md โ 5 minutes to first search.
# 1. Install Ollama for vector search (optional but recommended)
curl -fsSL https://ollama.com/install.sh | sh
ollama pull nomic-embed-text # ~274MB
# 2. Install Rewind
pip install rewind-memory
# 3. Ingest your files
rewind ingest ~/my-project/docs/
# 4. Search
rewind search "what was decided about auth"
Commands
| Command | Description |
|---|---|
rewind ingest <path> |
Ingest files into memory |
rewind search <query> |
Search memory |
rewind health |
Health check |
rewind doctor |
Auto-diagnose and fix issues |
rewind watch |
Real-time session watcher (NEW in 0.4.7) |
rewind ingest-chats |
Historical conversation backfill (NEW in 0.4.7) |
rewind watch-sessions |
Real-time conversation capture โ indexes sessions as they happen |
rewind serve |
API server + background file watcher |
rewind remember <text> |
Store a manual note in memory |
rewind bench |
Run LoCoMo benchmark |
rewind proxy |
Memory-augmented LLM proxy |
rewind migrate |
Migrate backends (Pro) |
Free vs Pro
| Feature | Free | Pro |
|---|---|---|
| L0 Keyword Search (FTS5) | โ | โ |
| L3 Knowledge Graph (SQLite) | โ | โ |
| L4 Vector Search (sqlite-vec) | โ (Ollama) | โ (NV-Embed-v2) |
rewind doctor |
โ | โ |
rewind watch |
โ (L0) | โ (L0 + L5) |
rewind watch-sessions |
โ (L0 + L3) | โ (L0 + L3 + L5) |
rewind ingest-chats |
โ (L0) | โ (L0 + L5) |
| OCPlatform gateway autopatcher | โ | โ |
| Memory Proxy | โ | โ |
| L5 Semantic Search (Qdrant) | โ | โ |
| L6 Document Store | โ | โ |
| Multi-channel awareness | โ | โ |
| Cloud GPU embeddings | โ | โ |
| Cross-encoder reranking | โ | โ |
| Memory extraction (post-turn) | โ | โ |
| Neo4j Knowledge Graph | โ | โ |
Usage
from rewind.client import RewindClient
from rewind.config import default_config
client = RewindClient(default_config("free"))
# Search across all layers
results = client.search("what is Hebbian learning")
for r in results:
print(f"{r.score:.2f} [{r.layer}] {r.text[:80]}")
# Ingest a document
client.ingest("notes/meeting.md")
# Health check
print(client.health())
CLI
# Search
rewind search "memory consolidation" --limit 10
# Ingest files
rewind ingest ./documents/
# Health check
rewind health
Integrations (Claude Code, Cursor, OpenClaw)
Rewind ships with an MCP server that works with any MCP-compatible tool:
Claude Code โ add to ~/.claude/settings.json:
{
"mcpServers": {
"rewind": {
"command": "rewind-mcp"
}
}
}
OpenClaw โ native hook (recommended) or gateway patch:
# Route memory_search through Rewind
rewind-ocplatform setup --url http://localhost:8031
# Native hook (recommended โ survives OpenClaw updates)
rewind-openclaw hook
rewind-openclaw hook --verify
rewind-openclaw hook --remove
# Gateway patch (legacy โ needs re-apply after updates)
rewind-openclaw patch
Cursor / Windsurf / Cline โ add rewind-mcp as an MCP server in settings.
See docs/INTEGRATIONS.md for full setup guides.
Memory Proxy (zero-config, works with any tool)
The proxy auto-injects memory into every LLM call. No MCP needed โ just change your API URL:
pip install rewind-memory[proxy]
# Ingest your project first
rewind ingest ./my-project/
# Start the memory proxy
rewind proxy --port 8080
Then point your tool at it:
# Cursor
OPENAI_BASE_URL=http://localhost:8080/v1 cursor .
# Aider
OPENAI_API_BASE=http://localhost:8080/v1 aider
# Any OpenAI-compatible tool
export OPENAI_BASE_URL=http://localhost:8080/v1
The proxy:
- Searches memory on every prompt (keyword + graph + vector fusion)
- Injects relevant context into the system message
- Auto-budgets injection size based on model context limits
- Passes through your API key to the upstream provider
- Supports streaming responses
- Works with OpenAI, Anthropic, NVIDIA, any OpenAI-compatible API
# Point at Anthropic instead of OpenAI
rewind proxy --port 8080 --upstream https://api.anthropic.com/v1
# Point at a local model
rewind proxy --port 8080 --upstream http://localhost:11434/v1
Configuration
# ~/.rewind/config.yaml
tier: free
workspace_path: ~/my-project
embedding:
provider: ollama
model: nomic-embed-text
url: http://localhost:11434
layers:
l0_sensory: true
l1_stm: true
l3_graph: true
l4_workspace: true
Upgrading
Rewind Core is free and fully functional as a local memory stack. For additional layers (communications, documents, bio lifecycle) and cloud GPU embeddings, see Rewind Pro.
Pro extends the Core package via a plugin โ install both and Pro layers activate automatically:
client = RewindClient(default_config("pro"), api_key="rw_live_...")
| Feature | Core (Free) | Pro ($9/mo) | MOS (Custom) |
|---|---|---|---|
| Keyword search (FTS5) | โ | โ | โ |
| System memory | โ | โ | โ |
| Knowledge graph (SQLite) | โ | โ | โ |
| Semantic vector search | โ local Ollama | โ cloud GPU (A10G) | โ custom GPU |
| HybridRAG fusion | โ 5-layer (L0โL4) | full 7-layer (L0โL6) | full 7-layer |
| Memory type taxonomy | โ (user/feedback/project/reference) | โ | โ |
| Recency weighting | โ (type-aware decay) | โ | โ |
| Query-intent matching | โ (boosts matching types) | โ | โ |
| Memory drift detection | โ (flags stale references) | โ | โ |
| OpenClaw gateway autopatcher | โ (pre-turn memory injection) | โ | โ |
| Communications memory (L5) | โ | โ | โ |
| Document store (L6) | โ | โ | โ |
| LLM relevance selection | โ | โ (cheap model side-query) | โ |
| Cross-encoder reranking | โ | โ (GPU-accelerated) | โ |
| Memory extraction (post-turn) | โ | โ (auto-extracts durable memories) | โ |
| Partial compaction | โ | โ (preserves task intent) | โ |
| Cloud GPU embeddings (NV-Embed-v2) | โ | 25K/mo included | custom volume rates |
| Retrieval feedback learning | โ | โ | โ |
| Migration assist (โ Neo4j/Qdrant) | โ | โ | โ |
| Bio lifecycle (decay, pruning) | โ | โ | โ |
| Air-gapped deployment | โ | โ | โ |
| Dedicated engineer + SLA | โ | โ | โ |
Real-Time Conversation Capture
Capture conversations as they happen โ no manual backfill needed:
# Watch all OpenClaw session files, index new turns into L0 + L3
rewind watch-sessions
# Custom session directory
rewind watch-sessions --session-dir /path/to/sessions
watch-sessions uses watchdog to monitor OpenClaw session JSONL files. When new conversation turns are written, they're immediately indexed into:
- L0 (BM25 keyword search)
- L3 (Knowledge graph โ entity extraction + co-occurrence edges)
This complements the gateway pre-turn hook: the hook reads memory before each turn, watch-sessions writes new conversations into memory after each turn. Together they form a closed loop.
Requires:
pip install 'watchdog>=3.0'
Development
git clone https://github.com/saraidefence/rewind-memory.git
cd rewind-memory
pip install -e ".[dev]"
pytest tests/
Patent
The 7-layer bio-inspired memory architecture is patent pending.
License
MIT โ see LICENSE.
Built by SARAI Defence. Ukrainian-built. Patent pending.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rewind_memory-0.5.8.tar.gz.
File metadata
- Download URL: rewind_memory-0.5.8.tar.gz
- Upload date:
- Size: 73.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7ab6e876c5bad97378c7df20293d1541f5fce56753457ddf33ccc8bc940582c
|
|
| MD5 |
5c73db1e6f66fcb13523f5b55fc47faf
|
|
| BLAKE2b-256 |
6e47e0a8e5a50b56a0448fdfdf546d98ed5a08ef701bc2e0b3fa0517dad75dea
|
File details
Details for the file rewind_memory-0.5.8-py3-none-any.whl.
File metadata
- Download URL: rewind_memory-0.5.8-py3-none-any.whl
- Upload date:
- Size: 77.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8868ad9a71f164bfb5f76c43ada92fc6462454443568dfe6f8f9d7bc0c60192
|
|
| MD5 |
0629bdce5ae9a8eb83165b21b929f583
|
|
| BLAKE2b-256 |
560f68d8bde2f8ff64c6aac0f2663ad13d7f34573e4080c7b093454c1fc08f73
|