← All posts

Giving AI agents memory that lasts: graph memory with Mem0, Zep, and Metis

Every new chat, your AI forgets you exist. It forgets the stack you use, the conventions you fought to establish, the gotcha you explained yesterday. You paste the same context again, and again, and call it a workflow.

That re-explaining is pure overhead, and it's the most underrated place to optimize an AI-assisted project. The fix is a memory layer: a store that captures facts and retrieves the relevant ones across sessions. And the good ones aren't a pile of text chunks — they're graphs.

Why a graph, not just a vector store

The first instinct is to throw everything into a vector database and semantic-search it. That works for "find me something similar," but facts in a real project aren't isolated blobs — they're relationships. "Service A calls B," "this rule supersedes that one," "Saurav prefers Kotlin over Java for new services." Entities and edges.

Plain vector recall struggles with two things: structure (multi-hop "what depends on what") and updates (a fact that's no longer true). A graph models both natively.

Mem0: the popular default

Mem0 is the one most people reach for — ~48K GitHub stars, Apache-2.0, fully self-hostable. Its architecture is a dual store: a vector DB for semantic recall plus a knowledge graph that captures entity relationships. Integration is genuinely a five-minute job:

from mem0 import Memory

m = Memory()
m.add("Prefers Kotlin + Spring Boot for new services; avoids Lombok", user_id="saurav")
m.add("Payout reconciliation must be idempotent on webhook retries", user_id="saurav")

m.search("what stack should I scaffold a new service in?", user_id="saurav")

Mem0 is the right call when you want personalization fast and your facts are mostly stable. The catch: it's vector-first with the graph as an add-on, and on the hosted plan the graph features sit behind the Pro tier.

Zep / Graphiti: graph-first and temporal

Zep, built on its open-source Graphiti engine, takes the opposite stance: graph-first, with time as a first-class dimension. When a fact changes — you switch the auth provider, a user changes jobs — Mem0 tends to store both versions and let the model sort out which is current from timestamps. Graphiti marks the old edge as superseded. Time is structure, not metadata.

That difference shows up in benchmarks: on the independent LongMemEval suite, Zep scored ~63.8% against Mem0's ~49% (GPT-4o), with most of the gap in knowledge-update and temporal-reasoning questions. The tradeoff is operational weight — self-hosting Graphiti means running and managing Neo4j (or FalkorDB/Kuzu) yourself.

The gap for coding tools — and why I built Metis

Mem0 and Zep are aimed at agent and application memory: remembering a user across a product. But AI coding assistants have a narrower, sharper need — project memory. The architectural decisions, conventions, and gotchas of a codebase, surfaced to whatever tool you happen to be using.

The wrinkle is delivery. Claude Code reads CLAUDE.md; Cursor reads .cursor/rules; Windsurf has its own. A memory layer that only answers API queries doesn't help if your assistant never calls it.

That's the problem Metis solves — it's the knowledge-graph context layer I've been building. It captures decisions and conventions into a structured graph, then compiles the relevant subset into the native context files each tool reads automatically, and syncs that across machines. Same graph idea as Mem0/Zep, pointed at a different target: instead of answering questions at runtime, it keeps the files your coding agent already reads continuously correct — no manual copy-paste across tools.

How to choose

  • Mem0 — fast personalization, mostly-stable facts, you'd rather buy automatic extraction than build it.
  • Zep / Graphiti — state that changes over time, point-in-time correctness matters, and you'll pay for the temporal graph in ops complexity.
  • Compile-to-context (Metis) — when the consumer is an AI coding tool and the win is keeping CLAUDE.md / .cursor/rules accurate without babysitting them.

Memory is the optimization that compounds. A better prompt helps once; a memory layer means every session your agent starts a little less ignorant than the last. That curve is worth investing in.