Memori

LLM-agnostic memory infrastructure that turns agent conversations into persistent, structured, recallable state.

Library
PyPI
v3.3.6
16,779stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
70/100Good
Development Activity64
Maintenance64
Community76
Maturity36
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture80
Code Quality82
Innovation76
Learning Curve78

Memori is agent-native memory infrastructure: an LLM-agnostic layer that captures what agents do and say during execution and turns it into structured, persistent memory that can be recalled later. It hooks into the LLM client you already use (OpenAI, Anthropic, Gemini, Bedrock, Grok, DeepSeek) or the agent framework you already build with (LangChain, Agno, Pydantic AI), so conversations and tool calls are persisted and recalled automatically in the background without rewriting prompts or application code.

Memories are attributed to an entity and a process and grouped into sessions, then enriched in the background with facts, preferences, relationships, rules, and skills through what the project calls Advanced Augmentation. Storage is pluggable: teams can use hosted Memori Cloud for zero-config setup, or bring their own database (Postgres, CockroachDB, MongoDB, TiDB, SQLite) for a fully self-hosted deployment, with a native Rust core handling embeddings and search underneath. On the LoCoMo long-conversation memory benchmark, Memori reports 87% overall accuracy while using roughly 2.8% of the token footprint of full-context prompting.

What You Get

  • Drop-in LLM client wrapping (OpenAI, Anthropic, Bedrock, Gemini, Grok, DeepSeek) and framework integrations (LangChain, Agno, Pydantic AI) that persist and recall memory with no prompt rewriting
  • Attribution and session model that scopes memories to an entity (user) and a process (agent/program), so recall stays correctly partitioned across users and agents
  • Advanced Augmentation that enriches raw conversation into attributes, events, facts, people, preferences, relationships, rules, and skills in the background with no added latency
  • Choice of hosted Memori Cloud (zero-config, dashboard with memories/analytics/playground) or self-hosted BYODB against Postgres, CockroachDB, MongoDB, TiDB, or SQLite
  • Native Rust core (via a bundled engine) for embeddings and hybrid FAISS + lexical search over stored memories
  • MCP server support for connecting coding agents (Claude Code, Cursor, Codex, Warp) directly to persistent memory with no SDK integration
  • A CLI for account, API key, and quota management shared across the Python and TypeScript SDKs

Common Use Cases

  • Giving a customer-support agent persistent recall of a user’s prior issues, preferences, and resolutions across sessions
  • Letting a coding assistant (via MCP) remember a team’s stack, conventions, and reviewer preferences across days of work
  • Adding long-conversation memory to a chat product without ballooning prompt size or re-sending full transcript history
  • Sharing structured team context (conventions, decisions) across multiple agents or programs scoped to the same project
  • Running an OpenClaw or Hermes agent gateway with automatic background memory capture and agent-controlled recall tools

Under The Hood

Architecture Memori splits cleanly into layered subpackages: llm/ (provider adapters, a registry, and invoke/pipelines layers reached by monkey-patching an existing client instance), memory/ (_collector.py, _writer.py, and _manager.py orchestrating capture and background augmentation), storage/ (_manager.py and _registry.py fronting pluggable adapters for dbapi, django, mongodb, and sqlalchemy plus a dedicated cockroachdb package), native/ (_adapter.py wrapping a compiled Rust core loaded via _loader.py, with a pure-Python fallback in _embeddings.py), search/ (_faiss.py and _lexical.py combined through _core.py), and provisioning/ (BYODB provisioning across storage providers). The top-level Memori class in init.py acts as a facade wiring together an LlmRegistry, an AugmentationManager, a StorageManager, and an optional RustCoreAdapter, while Agent (agent.py) is a thin HTTP client for Memori Cloud’s recall and compaction endpoints. Memory.Manager.execute() branches between cloud persistence (with retry/backoff in _handle_cloud) and local Writer-based persistence, showing a genuine dual-mode design rather than a cloud-only wrapper; changing the core LLM-registration contract would ripple through every adapter under llm/_providers.py and the invoke/pipelines layers, since they all conform to the same registration interface.

Tech Stack The Python SDK targets Python 3.10+ and depends on aiohttp for async HTTP, requests for sync calls, botocore for AWS/Bedrock integration, grpcio and protobuf for internal RPC/serialization, numpy and faiss-cpu for vector search, and pyfiglet for CLI banner art. A native Rust core (core/, with its own Cargo.toml, bindings, and Rust test suite) is compiled and loaded through _rust_core.py/_loader.py to accelerate embeddings, with a pure-Python fallback path when the compiled extension is unavailable. Storage is backend-agnostic through optional extras: sqlalchemy for relational access, psycopg for CockroachDB/Postgres, and pymysql/certifi for TiDB. The project ships a parallel TypeScript SDK (memori-ts/) plus separate Hermes and OpenClaw integration packages, each with its own CI workflow (ci.yml, core-ci.yml, ts-ci.yml, integration.yml), reflecting a genuinely polyglot, multi-surface distribution rather than a single-language project with bindings bolted on.

Code Quality Testing is extensive: a tests/ tree mirrors the source layout (memory/, storage/, llm/, embeddings/, provisioning/, database/, build/) plus dedicated integration/ and integration_v2/ suites, all run under pytest with pytest-asyncio, pytest-mock, and pytest-benchmark, with coverage thresholds and term/html/xml reporting configured directly in pyproject.toml. Error handling favors explicit fallback over silent failure: adapter code in native/_adapter.py catches narrow exceptions, logs with logger.exception, and degrades gracefully (e.g. embedding without the Rust core) instead of crashing or swallowing the error. The codebase is fully typed (a py.typed marker and a strict ty type-checker configuration) and enforced with ruff (pycodestyle, pyflakes, isort, bugbear, comprehensions, pyupgrade rule sets), pre-commit hooks, and a bandit security scan in the dev dependency group, all wired into CI.

API Design The primary integration path is a single call, Memori().llm.register(client), which instruments an existing LLM client object in place; attribution and session management are exposed as small, explicitly named methods (.attribution(), .new_session(), .set_session()) rather than buried configuration. The Python and TypeScript SDKs mirror each other’s API shape closely, keeping cross-language documentation consistent. Getting started requires only an API key and an LLM provider key as environment variables, and the CLI (python -m memori) handles account and quota management separately from the core library, keeping the primary interface small and focused.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search