The Problem
LLM agents have no persistent state. Every conversation starts from zero, so users re-explain preferences, agents re-discover context, and production systems can't audit what an agent actually knew. Memori turns agent execution and conversation into structured, queryable memory that survives across sessions.
What This Does
Memori is an agent-native memory layer that sits between your LLM and your datastore. It intercepts conversations and executions, extracts structured facts, and recalls them on demand. The repo implements this as a Rust core (core/src/lib.rs) with Python and TypeScript bindings, plus higher-level SDKs in memori/ (Python) and memori-ts/ (TypeScript).
The system is LLM-agnostic, datastore-agnostic, and framework-agnostic. It plugs into existing infrastructure — the README shows registering an OpenAI client and having memory persisted automatically. A managed cloud version exists at memorilabs.ai, with self-hosted options.
How It Is Wired
Execution starts in the Rust core. The entry points are core/src/runtime/worker.rs — start, submit, flush, shutdown — and core/bindings/python/src/lib.rs — execute. The Python binding calls back into the runtime via call_json_callback, fetch_embeddings, fetch_facts_by_ids, and write_batch. The Node bridge (core/bindings/node/src/bridge.rs) mirrors this pattern with PendingEmbeddingsMap, PendingFactsMap, and PendingWritesMap.
The core flow: execute → call_json_callback → model inference → write_batch → datastore. That's three hops from entry to persistence. The shutdown function is the widest blast radius — called from 9 places — so changing its behavior ripples through the entire runtime. The import graph shows a hub: memori/__init__.py has 62 modules depending on it, making it a high-churn, high-risk file.
The module graph also shows 23 modules inside circular dependencies, including memori/__init__.py and memori/llm/_base.py. Breaking those cycles requires extracting shared types or deferring imports — a non-trivial refactor.
How To Use It
Setup: Install the Python SDK (pip install memori) or TypeScript SDK (npm install @memorilabs/memori). For self-hosting, build the core with cargo build from core/.
Configuration: Set MEMORI_API_KEY and your LLM API key (e.g., OPENAI_API_KEY) in your environment. The .env.example file lists available options.
Running it: The README quickstart shows registering an OpenAI client and having memory persist automatically:
from memori import Memori
from openai import OpenAI
client = OpenAI()
mem = Memori().llm.register(client)
mem.attribution(entity_id="user_123", process_id="support_agent")
Real-World Use
A customer support agent that remembers user preferences across sessions. Register the LLM client, attribute the conversation to a user ID, and the system extracts and recalls facts like "favorite color is blue" without explicit memory management. Retrieval functions like search_facts and run_retrieval are called from 6 and 4 places respectively, indicating a well-used recall path.
Code Health & Issues
Static analysis found 136 findings (47 high, 89 medium) across 6 kinds. The most significant:
- High - Import cycle members (15):
memori/__init__.py,memori/llm/_base.py,memori-ts/src/core/config.tsparticipate in circular dependencies. - High - Deep nesting (18):
memori/llm/_base.pyreaches indentation depth 11; control flow is hard to follow. - High - Hub modules (7):
memori/__init__.pyhas 62 dependents; changes here are high-blast-radius. - Medium - Broad exception handling (16):
memori/__init__.pyswallows errors indiscriminately. - Medium - Oversized file:
memori/storage/drivers/mysql/_driver.pyat 728 lines.
SDLC observations from the structure: CI exists via GitHub Actions, tests are present (189 test files), and a license is committed. The health audit flags two high-severity items: unpinned GitHub Actions (tags can be moved) and a missing lockfile for benchmarks/pyproject.toml.
The Bottom Line
Memori is a serious attempt at solving agent memory, with a clean Rust core and solid SDK coverage. The main risks are the circular imports and hub modules that make refactoring expensive. Worth evaluating if you need persistent agent state and can tolerate the maintenance cost of a polyglot codebase.