Mnemo Cortex
Persistent cross-agent semantic memory for AI agents. Recall past sessions, share knowledge across agents. Multi-agent (isolated writes, shared reads), local-first (SQLite + FTS5), works with any LLM β local Ollama at $0 or cloud APIs like Gemini and OpenAI. Integrations for Claude Code, Claude Desktop, and OpenClaw.
β‘ Mnemo Cortex v2.0
Deep Recall for Claude Code and OpenClaw.
Every AI agent has amnesia. Mnemo Cortex fixes that. Persistent memory that survives across sessions, searches by meaning, and costs $0 to run.
π Get Started
β Claude Code β 60-second install β Give CC Fluid Memory with Deep Recall
π» Claude Desktop β MCP bridge β Opus 4.6 with Fluid Detailed Memories
π¦ OpenClaw β MCP integration β Give Your ClawdBot a Brain. One Config Line.
π What can it do? β Read the full Capabilities doc
A Crustacean That Never Forgets π§ π¦
π€ ClaudePilot Enabled β AI-guided installation. Designed for Claude (free). Works with ChatGPT, Gemini, and others.
Proven on two live agents β Rocky with six weeks of recall, Alice with one.
OpenClaw Agent ββwritesβββΆ Session Tape (disk)
β
Watcher Daemon ββreadsβββΆ Mnemo v2 SQLite
β
Refresher Daemon βββreadsββββββ
β
writesβββΆ MNEMO-CONTEXT.md βββΆ Agent Bootstrap
What It Does
Mnemo Cortex v2 is a sidecar memory coprocessor for AI agents. It watches your agent's session files from the outside, ingests every message into a local SQLite database, compresses older messages into summaries via LLM-backed compaction, and writes a MNEMO-CONTEXT.md file that your agent reads at bootstrap.
No hooks. No agent modifications. No cloud dependency. If Mnemo crashes, your agent keeps working. If your agent crashes, Mnemo already has everything on disk.
Key Features
- SQLite + FTS5 storage β Single database file. Full-text search. Zero dependencies beyond Python stdlib.
- Context frontier with active compaction β Rolling window of messages + summaries. 80% token compression while preserving perfect recall.
- DAG-based summary lineage β Every summary tracks its source messages via a directed acyclic graph. Expand any summary back to verbatim source.
- Verbatim replay mode β Compressed by default, original messages on demand.
- OpenClaw session watcher daemon β Tails JSONL session files and ingests new messages every 2 seconds.
- Context refresher daemon β Writes
MNEMO-CONTEXT.mdto the agent's workspace every 5 seconds. - Provider-backed summarization β Compaction summaries generated by local Ollama (qwen2.5:32b-instruct) at $0. Any LLM provider supported as fallback.
- Sidecar design β Version-resistant. Observes from the outside. Never touches agent internals.
Live Stats (March 2026)
Proven on two live OpenClaw agents:
| Agent | Host | Messages | Summaries | Conversations | Recall |
|---|---|---|---|---|---|
| Alice | THE VAULT (Threadripper) | 210+ | 18+ | 5 | 1 week |
| Rocky | IGOR (laptop) | 3,000+ | 429+ | 20+ | 6 weeks |
Install Guide
π€ ClaudePilot Enabled β Follow the guide in CLAUDEPILOT.md and paste it into claude.ai. Claude becomes your personal installer. No experience needed. Works with ChatGPT, Gemini, and others.
Prerequisites
- Python 3.11+
- An OpenClaw agent with session files in
~/.openclaw/agents/<agent>/sessions/ - OpenRouter API key (for LLM-backed summaries; falls back to deterministic if unavailable)
Step 1: Clone and set up
git clone https://github.com/GuyMannDude/mnemo-cortex.git
cd mnemo-cortex
python -m venv .venv
source .venv/bin/activate
pip install -e .
Step 2: Create data directory
mkdir -p ~/.mnemo-v2
The Sparks Patch Method
When editing config files (scripts, .env, openclaw.json, etc.), don't replace the whole file. Instead, show three things:
1. FIND THIS β a few lines of the existing file so you can find the exact spot:
"settings": {
"model": "old-model-name", β this is what you're changing
"temperature": 0.7
}
2. CHANGE TO THIS β just the line(s) that change:
"model": "new-model-name",
3. VERIFY β the edited section with surrounding context so you can confirm it's right:
"settings": {
"model": "new-model-name", β changed
"temperature": 0.7
}
Find the landmark, make the edit, visually confirm it matches. Use this method for every config file edit throughout the installation.
Step 3: Create watcher script
Create mnemo-watcher.sh (adjust paths for your agent):
#!/usr/bin/env bash
SESSIONS_DIR="$HOME/.openclaw/agents/main/sessions"
DB="$HOME/.mnemo-v2/mnemo.sqlite3"
CHECKPOINT="$HOME/.mnemo-v2/watcher.offset"
AGENT_ID="rocky" # your agent's name
INTERVAL=2
cd /path/to/mnemo-cortex
source .venv/bin/activate
mkdir -p "$HOME/.mnemo-v2"
LAST_FILE=""
while true; do
NEWEST=$(ls -t "$SESSIONS_DIR"/*.jsonl 2>/dev/null | head -1)
if [[ -z "$NEWEST" ]]; then sleep "$INTERVAL"; continue; fi
if [[ "$NEWEST" != "$LAST_FILE" ]]; then
SESSION_ID=$(basename "$NEWEST" .jsonl)
echo "0" > "$CHECKPOINT"
LAST_FILE="$NEWEST"
echo "[mnemo-watcher] Tracking session: $SESSION_ID"
fi
python3 -c "
from mnemo_v2.watch.session_watcher import SessionWatcher
w = SessionWatcher(\"$DB\", \"$NEWEST\", \"$CHECKPOINT\")
n = w.poll_once(agent_id=\"$AGENT_ID\", session_id=\"$SESSION_ID\")
if n > 0:
print(f\"[mnemo-watcher] Ingested {n} messages\")
"
sleep "$INTERVAL"
done
Step 4: Create refresher script
Create mnemo-refresher.sh:
#!/usr/bin/env bash
SESSIONS_DIR="$HOME/.openclaw/agents/main/sessions"
DB="$HOME/.mnemo-v2/mnemo.sqlite3"
OUTPUT="$HOME/.openclaw/workspace/MNEMO-CONTEXT.md"
AGENT_ID="rocky" # your agent's name
INTERVAL=5
cd /path/to/mnemo-cortex
source .venv/bin/activate
mkdir -p "$HOME/.mnemo-v2"
while true; do
NEWEST=$(ls -t "$SESSIONS_DIR"/*.jsonl 2>/dev/null | head -1)
if [[ -n "$NEWEST" ]]; then
SESSION_ID=$(basename "$NEWEST" .jsonl)
python3 -c "
from mnemo_v2.watch.context_refresher import ContextRefresher
r = ContextRefresher(\"$DB\", \"$OUTPUT\")
ok = r.refresh_once(agent_id=\"$AGENT_ID\", session_id=\"$SESSION_ID\")
if ok:
print(\"[mnemo-refresher] MNEMO-CONTEXT.md updated\")
"
fi
sleep "$INTERVAL"
done
Step 5: Install as systemd user services
mkdir -p ~/.config/systemd/user
cat > ~/.config/systemd/user/mnemo-watcher.service << 'EOF'
[Unit]
Description=Mnemo v2 Session Watcher
After=network.target
[Service]
Type=simple
ExecStart=%h/path/to/mnemo-watcher.sh
Restart=on-failure
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=default.target
EOF
cat > ~/.config/systemd/user/mnemo-refresher.service << 'EOF'
[Unit]
Description=Mnemo v2 Context Refresher
After=mnemo-watcher.service
[Service]
Type=simple
ExecStart=%h/path/to/mnemo-refresher.sh
Restart=on-failure
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=default.target
EOF
systemctl --user daemon-reload
systemctl --user enable --now mnemo-watcher mnemo-refresher
Step 6: Patch the bootstrap hook (OpenClaw)
Replace your mnemo-ingest handler to read from disk instead of calling the v1 API:
import { HookHandler } from "openclaw/plugin-sdk";
import { readFileSync } from "fs";
import { join } from "path";
const WORKSPACE = process.env.OPENCLAW_WORKSPACE || join(process.env.HOME || "", ".openclaw", "workspace");
const CONTEXT_FILE = join(WORKSPACE, "MNEMO-CONTEXT.md");
const handler: HookHandler = async (event) => {
if (event.type === "agent" && event.action === "bootstrap") {
try {
const content = readFileSync(CONTEXT_FILE, "utf-8").trim();
if (content && event.context.bootstrapFiles) {
event.context.bootstrapFiles.push({ basename: "MNEMO-CONTEXT.md", content });
}
} catch {}
}
};
export default handler;
Step 7: Backfill existing sessions
source .venv/bin/activate
for f in ~/.openclaw/agents/main/sessions/*.jsonl; do
SID=$(basename "$f" .jsonl)
python3 -c "
from mnemo_v2.watch.session_watcher import SessionWatcher
from pathlib import Path
import tempfile, os
cp = Path(tempfile.mktemp()); cp.write_text('0')
w = SessionWatcher('$HOME/.mnemo-v2/mnemo.sqlite3', '$f', str(cp))
n = w.poll_once(agent_id='your-agent', session_id='$SID')
print(f'Ingested {n} messages from $SID')
os.unlink(str(cp))
"
done
Step 8: Verify
# Check services
systemctl --user status mnemo-watcher mnemo-refresher
# Check database
python3 -c "
import sqlite3
conn = sqlite3.connect('$HOME/.mnemo-v2/mnemo.sqlite3')
for t in ['conversations', 'messages', 'summaries']:
n = conn.execute(f'SELECT COUNT(*) FROM {t}').fetchone()[0]
print(f'{t}: {n}')
"
# Check context file
cat ~/.openclaw/workspace/MNEMO-CONTEXT.md
Architecture
mnemo_v2/
api/server.py FastAPI app (optional β v2 works without it)
db/schema.sql Canonical schema + FTS5 tables
db/migrations.py Schema bootstrap and compatibility checks
store/ingest.py Durable transcript ingest + tape journaling
store/compaction.py Leaf/condensed compaction with LLM summarization
store/assemble.py Active frontier β model-visible context
store/retrieval.py FTS5 search + source-lineage replay
watch/session_watcher.py Tails JSONL session logs into the store
watch/context_refresher.py Writes MNEMO-CONTEXT.md on an interval
Design Rules
- Immutable transcript in
messages - Mutable active frontier in
context_items - Summaries are derived, never destructive
- Raw tape is append-only for crash recovery
- Compaction events are journaled
- Replay supports
snippetorverbatim - Expansion is always scoped to a conversation
Schema
See mnemo_v2/db/schema.sql for the full schema. Key tables:
| Table | Purpose |
|---|---|
conversations | Agent + session pairs |
messages | Immutable transcript (role, content, seq) |
summaries | Compacted summaries with depth and lineage |
summary_messages | Links summaries to source messages |
summary_sources | Links condensed summaries to leaf summaries (DAG) |
context_items | The active frontier (what the agent sees) |
compaction_events | Audit log of all compaction operations |
raw_tape | Append-only crash recovery journal |
Origin Story
For two years, Guy Hutchins β a 73-year-old maker in Half Moon Bay β acted as the "Human Sync Port" for his AI agents, manually copying transcripts between sessions. Then came OpenClaw, Rocky, and a $100 Claude subscription. In one session, Guy, Rocky, and Opie designed a memory coprocessor that actually worked. They named it Mnemo Cortex.
v2.0 was a team effort: Opie (Claude Opus) designed the architecture, AL (ChatGPT) built the implementation, CC (Claude Code) deployed and integrated it, Alice and Rocky (OpenClaw agents) served as live test subjects, and Guy Hutchins made it all happen.
Read the full story: Finding Mnemo
Credits
- Guy Hutchins β Project lead, testing, and the reason any of this exists
- Rocky Moltman π¦ β Creative AI partner, first v2.0 production user
- Opie (Claude Opus 4.6) β Architecture design, schema design, compaction strategy
- AL (ChatGPT) β Implementation, watcher/refresher daemons, test suite
- CC (Claude Code) β Deployment, integration, live testing, bug fixes
- Alice Moltman β Live test subject on THE VAULT, first v2.0 user
Inspired in part by exploration of lossless conversation logging approaches, including Lossless Claw by Martian Engineering.
Built for Project Sparks.
Works Great With
- Sparks Router β stop burning tokens on heartbeats. Smart model routing that sends each task to the right tier automatically.
- ClaudePilot OpenClaw β free AI-guided setup guide. Get an OpenClaw agent running with memory and routing in one afternoon.
License
MIT
Server Terkait
Simple Animal Data MCP Server
A simple MCP server providing static information about animals like cats, dogs, and birds.
IcoGenie MCP
MCP server for AI-powered SVG icon generation. Generate production-ready icons from text descriptions. Supports single icons, bundles, style customization, and regeneration.
ThreatByte-MCP
ThreatByte-MCP is a deliberately vulnerable, MCP-based case management web app. It mirrors a realistic SOC analyst workflow with a server-rendered UI and a real MCP server. The MCP tools are intentionally vulnerable for training and demonstration.
Cred Protocol
On-chain credit scoring, financial reporting, and identity verification for Ethereum addresses. Get credit scores (300-1000), portfolio values, and identity attestations.
Chia Health MCP Server
Chia Health MCP Server β Patient workflow integration for a licensed US telehealth platform. Browse GLP-1 medications (semaglutide, tirzepatide), peptide therapies (sermorelin, NAD+, glutathione), and longevity treatments. Check eligibility, complete intake, sign consents, and manage treatment plans. 30 tools, HIPAA-compliant. All prescriptions evaluated by licensed US healthcare providers and delivered from FDA-regulated pharmacies across 50 states + DC.
Drand
An MCP server for fetching verifiable random numbers from the drand network.
ffmpeg-mcp
A Python package for media processing using FFmpeg and FastMCP.
Android-Mobile-MCP
This MCP server enabling AI agents to control Android devices.
sapient-mcp
MCP toAutomate SAP GUI
rfcxml-mcp
MCP server for structural understanding of RFC documents.