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 external 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 proxy Memory-augmented LLM proxy
rewind migrate Migrate backends (Pro)

Free vs Pro

Feature Free Pro
L0 Keyword Search (FTS5) โœ… โœ…
rewind doctor โœ… โœ…
rewind watch (L0) โœ… โœ…
rewind ingest-chats (L0) โœ… โœ…
L5 Semantic Search (Qdrant) โŒ โœ…
Multi-channel awareness โŒ โœ…
Session Extractor โŒ โœ…
Session Continuity โŒ โœ…
Neo4j Knowledge Graph โŒ โœ…
Memory Proxy โœ… โœ…

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 โ€” config setup + optional gateway pre-turn hook:

# Route memory_search through Rewind
rewind-openclaw setup --url http://localhost:8031

# Patch the gateway to auto-inject memory into EVERY inbound message
# (the agent gets memory context before it even starts thinking)
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 โ€” โ€” โœ…

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

Apache License 2.0 โ€” 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.1.tar.gz (53.0 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.1-py3-none-any.whl (56.3 kB view details)

Uploaded Python 3

File details

Details for the file rewind_memory-0.5.1.tar.gz.

File metadata

  • Download URL: rewind_memory-0.5.1.tar.gz
  • Upload date:
  • Size: 53.0 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.1.tar.gz
Algorithm Hash digest
SHA256 2394b3c1fad3f42a1f5823d6829e46e0f5c75f1fa2819b849a3efa80ff048eaf
MD5 ecd0fea87d1623c20f4626d1b246bace
BLAKE2b-256 9b00415f9dfff61db689402268376b1b218d8c94149a2c94c969dc2a651ebbcd

See more details on using hashes here.

File details

Details for the file rewind_memory-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: rewind_memory-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 56.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a64948eef79f548ca180a836a1a6dfd4635605fea38f0ee406598f09bb1e34b0
MD5 e8eacb4816e6b8d48ae04225e37f4de8
BLAKE2b-256 7936aafa832d76a0b066af5f1aa145dd62c2e95693792af98a70a2611619e93a

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