Skip to main content

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

rewind_memory-0.5.8.tar.gz (73.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rewind_memory-0.5.8-py3-none-any.whl (77.2 kB view details)

Uploaded Python 3

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

Hashes for rewind_memory-0.5.8.tar.gz
Algorithm Hash digest
SHA256 a7ab6e876c5bad97378c7df20293d1541f5fce56753457ddf33ccc8bc940582c
MD5 5c73db1e6f66fcb13523f5b55fc47faf
BLAKE2b-256 6e47e0a8e5a50b56a0448fdfdf546d98ed5a08ef701bc2e0b3fa0517dad75dea

See more details on using hashes here.

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

Hashes for rewind_memory-0.5.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f8868ad9a71f164bfb5f76c43ada92fc6462454443568dfe6f8f9d7bc0c60192
MD5 0629bdce5ae9a8eb83165b21b929f583
BLAKE2b-256 560f68d8bde2f8ff64c6aac0f2663ad13d7f34573e4080c7b093454c1fc08f73

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page