Mimir
Issues · Contributing · Code of Conduct · Security · License
The agent memory that has to earn its keep.
You've felt this: your coding agent nails a fix, you move on, and three sessions later it makes the exact same mistake again. Every "memory" tool promises to fix this by hoarding everything it sees: every file, every message, every guess, and hoping that helps next time. Most of the time it doesn't. It just makes retrieval slower.
Mimir does the opposite. It watches your agent fail, turns that failure into one specific, testable lesson (a skill your agent actually earns, not a memory dump), and keeps it only if a real before/after benchmark proves the agent performs measurably better with it. No proof, no lesson. Ever. Every lesson that does survive is HMAC-signed and traceable back to the failure that created it, so nothing enters your agent's context without a paper trail.
Install it once. Capture runs quietly in the background of every Claude Code session; it never blocks, never raises. From then on your agent gets sharper the more you use it, and you can always see exactly which lesson fixed which mistake.
v0.1.0. The full lifecycle (capture, consolidate, recall, forget) works end-to-end and is covered by CI. Pre-1.0: interfaces can still move.
How it works
Mimir watches an agent work, distills its failures into lessons, and serves those lessons back, with a paper trail at every step.
capture (fast path) consolidate (slow path) recall (MCP)
───────────────────── ───────────────────────── ─────────────────
Claude Code hook logs ──► LLM judge extracts a rule ──► confidence-gated
EPISODEs (action / from failure episodes; retrieval over the
context / consequence) contradiction check, then LanceDB
to append-only JSONL. HMAC-signed LESSON written vector store, served
Never blocks, never to the vector store. as MCP tools.
raises.
The unit of memory:
- EPISODE: raw experience: what the agent did, in what context, with what consequence, scored by a deterministic verifier.
- LESSON: a distilled, specific directive (never "be careful") with a
confidence score that moves only on scored evidence, an HMAC-SHA-256
citation back to its supporting episodes, and a bi-temporal lifecycle
(
active → quarantined / superseded / retired; never hard-deleted).
What this looks like day to day
- You install it once. The hook logs failures in the background; you never think about it again during a normal session.
- Consolidation happens on its own. Once enough new failures pile up
(5 by default) and enough time has passed since the last run (4 hours
by default), the next hook call quietly spawns a background
mimir consolidatefor you, no command to remember. Runmimir consolidateyourself any time for an on-demand pass, or setMIMIR_AUTO_CONSOLIDATE=0to go back to fully manual. - From then on, recall is automatic. Every session after that, the agent pulls in whatever lessons actually clear the bar for the context it's in; you don't ask for it, you just notice fewer repeat mistakes.
- You can always audit why. Every lesson traces back to the specific
failure and the benchmark that proved it helped, and every
auto-consolidate run is logged to
~/.mimir/auto_consolidate.log.mimir.forgetretires a lesson instantly if it ever stops earning its keep.
The benchmark (why "prove" isn't a metaphor)
bench/ contains a WARM/COLD attribution harness: the same tasks are run by
an agent with Mimir's lessons (WARM) and without (COLD), with seeded runs, a
held-out probe set, and an ε-gate: a lesson is only admitted if the measured
lift clears the noise floor. This is the core bet: memory you can't attribute
to an outcome improvement is just storage.
| Typical memory layer | Mimir | |
|---|---|---|
| What gets kept | Everything it sees | Only what clears the ε-gate |
| Evidence | "Should help" | WARM vs. COLD, seeded, noise-banded |
| Can you reproduce the claim? | Usually not, take the vendor's word | Yes, demo_band() is one command, on your machine |
| Traceability | Opaque blob | HMAC-signed, cited back to the failing episode |
pytest tests/test_live.py # token-free: injected fake model
python -c "from bench.live import demo_band; demo_band(3)" # live: real Claude via your CLI, ~27 calls
The live run prints each arm's mean success rate with a (min, max) noise band. A WARM−COLD lift smaller than the band is reported as noise, not a result.
Visual scoreboard (Sonnet 5)
Run the three arms live against Sonnet 5 and render a self-contained page:
MIMIR_CLAUDE_MODEL=sonnet python -m bench.scoreboard --repeats 3
open bench/scoreboard/index.html
--repeats 3 draws 3×3 tasks per arm for a noise band (27 solver calls); use
--repeats 1 for a quick single run (9 calls). The page reads data.js and
needs no server; open it directly and screen-record the bars filling in.
Quickstart
pip install 'mimir-agent-memory[mcp]'
mimir setup
Two commands. The first installs Mimir with the MCP extras. The second
registers the capture hook into Claude Code (~/.claude/settings.json) and
registers mimir-serve as an MCP server (via claude mcp add, if the
claude CLI is on PATH; otherwise it says so and capture still works on
its own). From here:
# Work normally. Failures get logged to ~/.mimir/episodes.jsonl.
# Consolidate: happens automatically in the background once enough
# failures pile up (see "day to day" above), or run it yourself:
mimir consolidate
Lessons then come back automatically through mimir.recall over MCP. What
you consolidate is what gets served, both sides run on the same
LanceDB-backed lesson store under ~/.mimir/.
Prefer to do it by hand, or your client isn't the claude CLI? mimir install-hook registers just the capture hook, and mimir-serve is a
stdio MCP server you can point any MCP client at directly.
Windows: pip installs the mimir/mimir-hook/mimir-serve commands into
%APPDATA%\Python\Python3XX\Scripts, which often isn't on PATH by default
(pip warns about this at install time). If mimir isn't found afterward, add
that folder to PATH (or run everything as python -m mimir.cli ...).
Also on Cline and Hermes: mimir install-hook --cline writes the
PostToolUse hook script Cline picks up automatically (capture only).
Hermes gets two drop-in plugins: hermes_plugin/ captures tool-call
failures the same way, and hermes_memory_plugin/ goes further: it
registers Mimir as an actual Hermes MemoryProvider, so mimir.recall
serves lessons straight into Hermes' prompt (memory.provider: mimir in
Hermes' config.yaml). New integrations, schemas not yet verified against a
live session; open an issue if
something doesn't map correctly.
Anything else: if your tool can run a shell command with JSON on
stdin, mimir hook --config <path> plugs it in without touching Mimir's
code; see docs/integrations/generic.md.
Semantic storage
Semantic storage and retrieval run directly on LanceDB
(mimir/store_semantic.py), no framework in between, just a thin, swappable
VectorIndex seam (LanceDB for a real on-disk store, or a zero-dependency
in-process cosine index for tests and low-footprint runs). The persisted
LESSON objects remain the source of truth; the vector index is a derived
cache, rebuilt from them on load.
The default embedder is a dependency-free token-hashing bag-of-words (good enough for shared-vocabulary matches, zero install cost). For real semantic recall, opt into a local fastembed model (ONNX, no torch, no network after the first download):
pip install 'mimir-agent-memory[embed]'
export MIMIR_EMBED_MODEL=BAAI/bge-small-en-v1.5 # any fastembed model name
Mimir implements the full memory lifecycle:
| Lifecycle stage | Where it lives in Mimir |
|---|---|
| remember | mimir install-hook + mimir.capture: episodes logged from real agent sessions |
| memify (improve) | mimir consolidate / mimir.consolidate: failures distilled into judged, ε-gated, HMAC-signed lessons in the LanceDB-backed store |
| recall | mimir.recall, served by mimir-serve: confidence-gated semantic retrieval over the LanceDB index |
| forget | mimir.forget: explicit, bi-temporal retirement; lessons are also auto-quarantined/superseded on contradicting evidence (never hard-deleted), and excluded from recall either way |
MCP tools
mimir-serve exposes the full lifecycle over stdio; any MCP client (Claude
Code included) can drive it directly:
mimir.capture(remember): log an episode directly (when not using the hook)mimir.consolidate(memify): distill logged failures into judged, ε-gated, HMAC-signed lessons in the LanceDB-backed storemimir.recall(recall): confidence-gated, semantically-ranked lesson retrieval for the current context. Not exposed at all when there's nothing to recall yet (e.g. right after install, before the first consolidate). No wasted round-trip on a call that could only ever come back empty.mimir.forget(forget): retire a lesson for good; bi-temporal, so the prior version stays on record for audit but is excluded from recall
mimir.attribute (single-lesson counterfactual credit) stays CLI/bench-only:
it needs an injected solver callable, bound only inside the C5 benchmark harness.
Development
git clone https://github.com/kirrns/mimir && cd mimir
pip install -e '.[dev,mcp]'
pytest
Python ≥ 3.10. The core package is dependency-free; mcp (protocol) and
lancedb (vector store) are the mcp extra, imported lazily so tests run
without either installed.
Contributions welcome; see CONTRIBUTING.md. This project follows the Contributor Covenant. Found a security issue? See SECURITY.md rather than opening a public issue.
License
Metadata
Release files for mimir-agent-memory 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| mimir_agent_memory-0.1.1.tar.gz | 66.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mimir_agent_memory-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 108.4 kB
Release files / mimir_agent_memory-0.1.1.tar.gz
| Download URL | mimir_agent_memory-0.1.1.tar.gz |
|---|---|
| Size | 66.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c249288b11594842631e3fbc86ac175ef34a01d11410fb06573bca19122c217a
|
|
BLAKE2b-256 checksum How to use checksums |
bb833423f6d0116fce1b2b66e3ba8848f2ef52cdf343cc6f4ae9a62426e703cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logRelease files / mimir_agent_memory-0.1.1-py3-none-any.whl
| Download URL | mimir_agent_memory-0.1.1-py3-none-any.whl |
|---|---|
| Size | 42.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae13df38939534f2e3c745772113510d83d396250b611e0089ab0a09b1e830b8
|
|
BLAKE2b-256 checksum How to use checksums |
07e6f8dd85c07f603602e05d53d4c618b2024ca16e1de4f98042cbea91ed6e01
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logSecurity for mimir-agent-memory 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for mimir_agent_memory-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jul 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.