Sandbox
@CodeAbra/iai-personal-memory-engine

Local memory engine for Claude Code and Codex

iai-personal-memory-engine is a local memory layer that records agent conversations, stores them verbatim, and feeds back the right context on later turns. It works through MCP tools, host hooks, a daemon, and a desktop dashboard, so the agent can recall facts, contradictions, and older wording without a hosted service.

873 stars106 forksPythonUpdated 7d ago
Who it's for

Builders who want their agent to keep long-term memory on their own machine.

What it delivers

You can stop re-explaining context and get the right past details, even when facts change over time.

What it does

Verbatim conversation capture

Records both sides of sessions word-for-word and keeps old wording when facts are revised.

MCP memory tools

Exposes recall, search, capture, contradiction, reinforcement, consolidation, and profile tools through MCP.

Host hooks and ambient recall

Adds session-start recall, turn capture, and per-turn updates for supported hosts like Claude Code and Codex.

Local encrypted store

Keeps the store on the user’s machine and encrypts records at rest with AES-256-GCM.

Dashboard and CLI

Provides `iai brain`, `iai recall`, `iai search`, `iai capture`, and related commands for inspecting and managing memory.

Benchmarks and validations

Includes a large `bench/` harness and benchmark notes for recall accuracy, latency, and storage behavior.

How to get it

  1. 1Run
    python3.12 -m pip install -U iai-pme
  2. 2Then run inside Claude Code
    /plugin marketplace add CodeAbra/iai-personal-memory-engine
    /plugin install iai-memory@iai-pme
  3. 3Restart the session, then verify
    iai --version
    iai-mcp daemon status
    iai-mcp doctor
  4. 4Run
    curl -fsSL https://raw.githubusercontent.com/CodeAbra/iai-personal-memory-engine/main/scripts/bootstrap.sh | bash
  5. 5This builds the Rust engine and TypeScript wrapper, installs the background service and…
    curl -fsSL https://raw.githubusercontent.com/CodeAbra/iai-personal-memory-engine/main/scripts/bootstrap.sh | bash -s -- --dry-run
  6. 6Run
    python3.12 -m pip install -U iai-pme
    iai-mcp crypto init
    iai-mcp daemon install
    iai-mcp capture-hooks install --target codex

README

English | 中文

iai-memory — a personal memory engine for your AI coding workflow

Keeps every conversation word-for-word and gives your AI agent the right
context on every turn — including the old wording when a fact changes.

iai-memory searching, recalling, pinning, fading, rescuing, and learning a file

iai-memory on PyPI MIT License Python 3.11 or 3.12 macOS and Linux supported Windows beta MCP compatible

Rescue@10 1.000 LongMemEval R@5 0.962 Historical-verbatim hit@10 1.000 AES-256-GCM at rest

Quick start · How it works · Benchmarks · Compatibility · Technical reference


What it is

Your AI agent forgets everything the moment you close the session. iai-memory fixes that, on your own machine. Switch the hooks on and it records both sides of every conversation word-for-word, then feeds the agent the part of your history that matters on every message — not just when a session starts. No memory file to maintain, no “remember this.”

When a fact changes, the old one isn't overwritten. The new version is stored and linked back to what it replaced, so you can still pull up both. When something contradicts itself, recall shows you the conflict instead of quietly handing over a stale answer as if it were true.

It's memory built around you and one agent — not a memory API for a multi-tenant app, and not a wrapper around someone else's database. What you say is stored once, verbatim, and never rewritten. The store, the search, the graph, the dashboard: all of it runs on your machine.

The memory style is autistic by design. It keeps the literal wording instead of smoothing it into a paraphrase, holds onto precise cues, and leaves rare things rare instead of averaging them away. Why the name.


Quick start

Claude Code

python3.12 -m pip install -U iai-pme

Then run inside Claude Code:

/plugin marketplace add CodeAbra/iai-personal-memory-engine
/plugin install iai-memory@iai-pme

Restart the session, then verify:

iai --version
iai-mcp daemon status
iai-mcp doctor

Python 3.11 is also supported.

macOS or Linux: all-in-one source install

curl -fsSL https://raw.githubusercontent.com/CodeAbra/iai-personal-memory-engine/main/scripts/bootstrap.sh | bash

This builds the Rust engine and TypeScript wrapper, installs the background service and hooks, registers Claude Code, and runs the health check. It requires Git, Python 3.11/3.12, Node.js 18+, and Rust. To inspect the steps without changing anything:

curl -fsSL https://raw.githubusercontent.com/CodeAbra/iai-personal-memory-engine/main/scripts/bootstrap.sh | bash -s -- --dry-run

Other hosts

python3.12 -m pip install -U iai-pme
iai-mcp crypto init
iai-mcp daemon install
iai-mcp capture-hooks install --target codex

Replace codex with cursor, antigravity, hermes, openclaw, or all. MCP tools work with any MCP-over-stdio client; automatic capture and context injection depend on the hooks exposed by the host. See the technical reference.

New stores use the native engine format by default; an existing store keeps its current format on upgrade. To move an existing legacy SQLite store onto the native engine, run iai-mcp migrate-to-lilliiai-mcp doctor prints the exact command, and the technical reference documents the full flow.


What happens after installation

EventAction
PromptNew turns are appended to a session buffer as file IO; no embedding or engine RPC is needed on the capture path
Session endRemaining transcript content is rolled over for ingestion; hook failures do not block the host
Session startA bounded memory prefix is exposed as host context; an empty store or unavailable engine yields empty output
Later turnsSupported hosts receive a small foresight or delta pack with age and revision markers
Idle timeCaptures are embedded, deduplicated, encrypted, inserted, clustered, consolidated, reinforced, and decayed

The background process is called the daemon in the CLI. The MCP wrapper and iai can still read the local store directly when it is asleep or temporarily unavailable.


How it works

Memory model

TierContains
EpisodicTimestamped, write-once fragments of what was said
SemanticSummaries induced from related episodes during idle consolidation
ProceduralTen bounded behavioural parameters learned over time

Distinct hyperdimensional representations keep literal detail, semantic structure, and behavioural tendencies from collapsing into one vector surface.

The local, LLM-free recall path combines semantic similarity, graph evidence, recency, temporal validity, and lexical evidence. memory_recall returns both hits and anti_hits; memory_contradict closes the old record's validity interval, creates a new record, and links the two.

While idle, the engine groups related episodes, induces semantic memory, reinforces useful paths, and decays weak unreviewed edges. One optional REM step may invoke claude -p through the user's existing Claude subscription, capped at no more than 1% of the daily quota. No Anthropic API key is required.

First-party components

ComponentRole
HippoEncrypted records, vector index, and graph in one local store
MOSAICLeiden-family community detection with stable community identity
Lilli HDHyperdimensional substrate and structural recall
Native engineRust embedder and graph kernels

Dashboard and CLI

iai brain

The local dashboard searches the store, exposes graph neighbourhoods and contradictions, pins or fades memories, ingests files, controls the background engine, and reports token-use estimates from your own store.

iai recall · temporal-recall · search · ask · capture · teach · upload
iai watch · brain · status · last

iai upload accepts documents, Office files, e-books, source code, configuration files, and directories. Full formats and administrative commands are listed in docs/REFERENCE.md.


Benchmarks

Every harness ships in bench/; methodology and reproduce commands are in BENCHMARKS.md.

BenchmarkResult
Rescue@10 after contradiction1.000
Historical-verbatim hit@101.000
LongMemEval-S R@5, product embedder0.962
LongMemEval-S R@10, product embedder0.978

Historical-verbatim retrieval uses a flat-cosine baseline of about 0.71. With the matched all-MiniLM-L6-v2 embedder, iai-memory and mempalace v3.3.6 both score R@5 0.966 and R@10 0.978; no win is claimed.

On the author's store, an automatically injected memory pack averaged about 350 tokens versus about 2,850 tokens for the agent-search round trip it replaced: approximately 88% cheaper on that measured workload. This does not apply to explicit memory_recall, whose default response budget is 1,500 tokens.


MCP tools

memory_recall              memory_temporal_recall
memory_recall_structural   memory_search
memory_capture             memory_contradict
memory_reinforce           memory_consolidate
profile_get_set            topology
schema_list                events_query
episodes_recent            curiosity_pending

Fourteen tools cover cue, temporal, structural, and lexical recall; capture and correction; reinforcement and consolidation; behavioural-profile control; and store introspection.


Compatibility

HostAmbient behaviour
Claude CodeSession-start recall, per-turn updates, turn capture, and session capture
Codex CLIFull integration through Codex hooks
CursorSession-start recall and capture; no per-turn text injection
AntigravityRecall per invocation and lossless transcript capture
Hermes 0.5.0+Recall before model calls and capture from its message store
OpenClawMCP tools on request; no ambient shell hooks
Gemini CLI and other MCP hostsMCP tools; no bundled host-specific hooks unless listed above
Claude DesktopMCP tools; plain Chat does not expose Claude Code-style ambient hooks

Privacy and limitations

  • Records are encrypted at rest with AES-256-GCM. The store and key live under ~/.iai-mcp/; back them up together.
  • macOS and Linux use a Unix socket. Windows uses an ephemeral loopback port with a per-user token.
  • There is no iai-memory account, telemetry pipeline, hosted dashboard, or cross-machine sync.
  • Optional iai-memory network activity is the REM claude -p step and a daily PyPI version check. Set IAI_MCP_VERSION_CHECK=0 to disable the check.
  • The store refuses to mix incompatible embedding generations; changing the embedder requires an explicit migration.
  • Recall is usually mediocre during roughly the first ten sessions, and quality and latency depend on corpus size, language, embedder, and stored history.
  • The default store is English-first. Raw non-English records require an explicit raw:<lang> tag and a multilingual or custom embedder.
  • Windows support is beta. Ambient behaviour varies with host hook support.
  • The project is solo-maintained and has no enterprise SLA.

Health and updates:

iai-mcp doctor          # 38 checks
iai-mcp daemon status
iai-mcp self-update

About the name

IAI — Independent Autistic Intelligence describes the memory design.

  • Independent: the engine, store, embeddings, and dashboard run locally.
  • Autistic: literal preservation, precise cues, sustained focus, and rare events retained as rare rather than smoothed into a typical summary. This is an operational design description, not a diagnosis or casual metaphor.
  • Intelligence: used in the systems sense — a process that observes, adapts, reorganizes itself, and remains viable over time.

“Personal memory engine” describes the scope: one person's memory, on one machine, used by the assistant they already have.


Documentation

Issues and pull requests are welcome. Changes to retrieval, capture, contradiction handling, or consolidation should include relevant benchmark reruns.

Authors

By Areg Aramovich Noya and Lilli Noya, in collaboration with the team at lcgc.dev.

License

MIT

Files in the repo

Repository payload32 top-level entries
  • .claude-plugin
  • .github
  • bench
  • crates
  • desktop
  • docs
  • fixtures
  • mcp-wrapper
  • plugin
  • rust
  • scripts
  • src
  • tests
  • .gitignore
  • BENCHMARKS.md
  • Cargo.lock
  • Cargo.toml
  • CHANGELOG.md
  • CODE_OF_CONDUCT.md
  • CONTRIBUTING.md
  • deny.toml
  • LICENSE
  • llms.txt
  • logo.png
  • MANIFEST.in
  • NOTICE.md
  • pyproject.toml
  • README_zh-CN.md
  • README.md
  • rust-toolchain.toml
  • SECURITY.md
  • setup.py

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More connectors

Real-time global intelligence dashboard. AI-powered news aggregation, geopolitical monitoring, and infrastructure tracking in a unified situational awareness interface

86k

High-performance code intelligence MCP server. Indexes codebases into a persistent knowledge graph — average repo in milliseconds. 158 languages, sub-ms queries, 99% fewer tokens. Single static binary, zero dependencies.

43k

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM (Claude, Gemini, Grok, DeepSeek, Ollama…) with Codex CLI, App, SDK, and Claude Code

14k
okf-memory/
okf-agent-memory

Git-native persistent memory for AI coding agents. Implements Google OKF v0.2 with sub-300µs in-memory BM25 search, embedded MCP server, and progressive disclosure. Slashes token bloat by 80% with zero external databases or dependencies. Built in pure Go.

547
tirth8205/
code-review-graph

Local-first code intelligence graph for MCP and CLI. Builds a persistent map of your codebase so AI coding tools read only what matters, with benchmarked context reductions on reviews and large-repo workflows.

31k
2akouwu/
reverify

Stop your AI from making things up — it proposes, deterministic tools decide, every claim checked against ground truth with evidence. Grounded facts and context survive resets. Reverse engineering is the proving ground. MCP server + CLI.

1.1k