<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Temporal Knowledge Graph on RockB</title><link>https://baeseokjae.github.io/tags/temporal-knowledge-graph/</link><description>Recent content in Temporal Knowledge Graph on RockB</description><image><title>RockB</title><url>https://baeseokjae.github.io/images/og-default.png</url><link>https://baeseokjae.github.io/images/og-default.png</link></image><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 24 Aug 2026 13:03:04 +0000</lastBuildDate><atom:link href="https://baeseokjae.github.io/tags/temporal-knowledge-graph/index.xml" rel="self" type="application/rss+xml"/><item><title>ContextNest vs Mem0 vs Zep: Anatomy of Persistent Memory for AI Agents</title><link>https://baeseokjae.github.io/posts/anatomy-of-persistent-memory-contextnest-vs-mem0-vs-zep/</link><pubDate>Mon, 24 Aug 2026 13:03:04 +0000</pubDate><guid>https://baeseokjae.github.io/posts/anatomy-of-persistent-memory-contextnest-vs-mem0-vs-zep/</guid><description>ContextNest vs Mem0 vs Zep aren&amp;#39;t rivals but three memory layers: Zep logs sessions, Mem0 extracts preferences, ContextNest governs corporate knowledge. Here&amp;#39;s when you need each.</description><content:encoded><![CDATA[<p>ContextNest vs Mem0 vs Zep is the wrong framing: these three are complementary layers of the same memory stack, not competing products. Zep provides session log memory, Mem0 handles personalization memory, and ContextNest governs corporate knowledge — and production agents typically need all three. A single memory database is the most common architectural pitfall, because it cannot serve session continuity, user personalization, and compliance-ready knowledge at the same time. This guide dissects each layer, compares them head-to-head, and shows how to stack them.</p>
<h2 id="the-anatomy-of-persistent-memory-why-one-memory-database-isnt-enough">The Anatomy of Persistent Memory: Why One Memory Database Isn&rsquo;t Enough</h2>
<p>Persistent memory in AI agents has a common failure mode: developers install a single memory database and expect it to solve everything. That expectation is wrong, and it is why so many &ldquo;agent memory&rdquo; projects stall. Memory is not one thing. It is at least three distinct functions with different write patterns, different retrieval semantics, and different trust requirements.</p>
<p>Session memory answers &ldquo;what happened in this conversation or across the last few sessions?&rdquo; It is high-frequency, high-volume, and mostly ephemeral. Personalization memory answers &ldquo;what does this user prefer?&rdquo; It is lower-frequency, semantically extracted, and must stay current as preferences change. Governance memory answers &ldquo;what does the organization actually know and approve?&rdquo; It is curated, versioned, and auditable, and it feeds the agent facts that must not be wrong.</p>
<p>The three tools in question map cleanly onto those three jobs. Zep is built around session logging and temporal facts. Mem0 extracts personalization from conversation. ContextNest is a governed, self-hosted knowledge vault. When you understand that they operate at different layers of the anatomy, the &ldquo;vs&rdquo; in the title stops being a competition and becomes a design decision: which layer do you need, and how do they fit together?</p>
<h2 id="layer-1--zep-session-log-memory-with-temporal-knowledge-graphs">Layer 1 — Zep: Session Log Memory with Temporal Knowledge Graphs</h2>
<p>Zep is the session layer. Its core contribution is a temporal knowledge graph that tracks facts with <code>valid_at</code> and <code>invalid_at</code> windows, so the agent knows not just what a fact is, but when it was true. That temporal awareness is the reason Zep leads long-horizon memory benchmarks.</p>
<p>The architecture is powered by Graphiti, Zep&rsquo;s open-source temporal knowledge graph engine, which has roughly 30,000 GitHub stars. Where flat vector stores treat a fact as a point in embedding space, Graphiti treats it as an entity with a lifespan. When a user changes their employer, for example, the old employment fact is not deleted — it is marked invalid as of a timestamp, and the new fact becomes valid. The agent can therefore reason correctly about &ldquo;where did they work last year&rdquo; versus &ldquo;where do they work now.&rdquo;</p>
<p>The benchmark numbers back this up. Zep scores 63.8% on LongMemEval, the de facto benchmark for long-horizon agent memory, against Mem0&rsquo;s 49.0% — a 15-point gap driven almost entirely by the temporal graph. On the DMR benchmark, Zep reaches 94.8% accuracy and 98.2% with GPT-4o Mini, setting state of the art. Zep also claims up to 90% response latency reduction versus stuffing the full chat history into context.</p>
<p>The main caveat is hosting. Zep&rsquo;s Community Edition was deprecated in April 2025. Self-hosting now requires running raw Graphiti against a graph database, which is a meaningfully heavier operational lift than a self-contained package. For most teams, Zep is effectively a managed service.</p>
<h2 id="layer-2--mem0-personalization-memory-via-semantic-extraction">Layer 2 — Mem0: Personalization Memory via Semantic Extraction</h2>
<p>Mem0 is the personalization layer, and it is the most widely adopted agent memory framework by far — roughly 64,000 GitHub stars as of August 2026. Its write path is different from Zep&rsquo;s. Instead of continuous logging, Mem0 runs autonomous semantic extraction: it watches a conversation stream, pulls out discrete preference and identity facts, and injects them back on the next turn.</p>
<p>Its headline economics are compelling. Mem0 claims up to 80% prompt token reduction through intelligent chat history compression, which directly lowers per-session cost. For a conversational product, that compression is the difference between a usable context window and one that fills up after a few turns.</p>
<p>The weakness is the stale-fact trap. Because Mem0 writes probabilistically, it relies on semantic matching to decide whether a new fact updates an existing one. When that update match fails, both the old and the new preference remain active in the graph. The LLM then has no deterministic way to disambiguate them, and it may surface a deprecated preference — an old pricing tier, an outdated endpoint, a former contact method — as if it were current. This is the core hallucination risk of pure semantic memory, and it is exactly the problem deterministic governance is designed to solve.</p>
<p>Mem0&rsquo;s more advanced graph features (Mem0g) are locked behind the Pro tier at $249 per month, which pushes teams toward either paying for the enterprise tier or accepting the limitations of the flat-vector free path.</p>
<h2 id="layer-3--contextnest-governed-corporate-knowledge-with-deterministic-vaults">Layer 3 — ContextNest: Governed Corporate Knowledge with Deterministic Vaults</h2>
<p>ContextNest is the governance layer, and it is deliberately different from the other two. It stores governed context in a local-first, self-hosted markdown vault that is versioned with Git and verified with SHA-256 hash chains. Nothing enters the agent&rsquo;s context unless it has been explicitly written, committed, and approved by a human steward.</p>
<p>The write pipeline is deterministic rather than probabilistic. Knowledge goes in through explicit commits, and a manual steward approval gates LLM access to it. When a file is deprecated, it is physically excluded via a deterministic <code>ctx forget</code> operation — not just down-weighted in a vector index. There is no window in which a stale fact and a current fact are both retrievable with equal confidence. This is the &ldquo;governed context&rdquo; architecture, and it is what makes ContextNest speak SOC 2, GDPR, and model-risk-management language.</p>
<p>Conceptually, ContextNest describes itself as a &ldquo;structured second brain.&rdquo; It turns repos, docs, Slack threads, and tribal knowledge into typed nodes with relationships and a selector grammar — a graph rather than a flat folder. The vault carries a CONTEXT.md identity plus nodes, sources, packs, and a context.yaml document graph. Skill nodes define reusable agent procedures with triggers, typed inputs, required tools, and guardrails.</p>
<p>The economics are striking. ContextNest claims roughly 100x cheaper agent sessions: a next session reads about 500 tokens of pre-digested, relevant context instead of stuffing 50,000 tokens of raw files into the window. Retrieval latency scales linearly — <code>context_query</code> p95 is 6ms at 100 docs, 74ms at 1,000, and 841ms at 10,000, with a per-document cost factor between 0.45x and 1.15x.</p>
<p>A key differentiator is integration. ContextNest is a native Model Context Protocol (MCP) server, connecting directly to compliant LLM clients like Claude and Cursor with no middleware roundtrip. Zep and Mem0 rely on custom SDKs or REST wrappers, which add network roundtrips between your agent and its memory. The npm packages are <code>contextnest-cli</code> (the <code>ctx</code> CLI), <code>contextnest-engine</code>, and <code>contextnest-mcp-server</code>. The standard is AGPL-3.0 with no vendor lock-in.</p>
<h2 id="side-by-side-contextnest-vs-mem0-vs-zep-feature-comparison">Side-by-Side: ContextNest vs Mem0 vs Zep Feature Comparison</h2>
<p>The differences collapse into a few axes. Here is the direct comparison:</p>
<table>
  <thead>
      <tr>
          <th>Dimension</th>
          <th>Zep</th>
          <th>Mem0</th>
          <th>ContextNest</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Primary role</td>
          <td>Session log memory</td>
          <td>Personalization memory</td>
          <td>Governed corporate knowledge</td>
      </tr>
      <tr>
          <td>Write path</td>
          <td>Continuous logging + auto-summarization</td>
          <td>Autonomous semantic extraction</td>
          <td>Explicit commits + steward approval</td>
      </tr>
      <tr>
          <td>Retrieval model</td>
          <td>Temporal knowledge graph</td>
          <td>Flat vector / semantic</td>
          <td>Deterministic selector grammar</td>
      </tr>
      <tr>
          <td>Stale-fact handling</td>
          <td><code>valid_at</code>/<code>invalid_at</code> windows</td>
          <td>Probabilistic; stale+current can coexist</td>
          <td>Deterministic <code>ctx forget</code>, physical exclusion</td>
      </tr>
      <tr>
          <td>Hosting</td>
          <td>Cloud-centric (CE deprecated 2025)</td>
          <td>Hosted SDK / self-managed</td>
          <td>Local-first, self-hosted, AGPL-3.0</td>
      </tr>
      <tr>
          <td>LongMemEval</td>
          <td>63.8%</td>
          <td>49.0%</td>
          <td>N/A (not a semantic memory benchmark)</td>
      </tr>
      <tr>
          <td>Token reduction</td>
          <td>Up to 90% latency reduction</td>
          <td>Up to 80% token reduction</td>
          <td>~100x cheaper sessions (~500 vs 50k tokens)</td>
      </tr>
      <tr>
          <td>Integration</td>
          <td>Custom SDK / REST</td>
          <td>Custom SDK / REST</td>
          <td>Native MCP server</td>
      </tr>
      <tr>
          <td>Stars</td>
          <td>~30K (Graphiti)</td>
          <td>~64K</td>
          <td>Lower (emerging)</td>
      </tr>
  </tbody>
</table>
<p>The pattern is clear: each tool optimizes a different axis. Zep optimizes temporal accuracy, Mem0 optimizes adoption and integration breadth, ContextNest optimizes trust and governance. None of them is a universal replacement for the others.</p>
<h2 id="the-stale-fact-problem-probabilistic-extraction-vs-deterministic-governance">The Stale-Fact Problem: Probabilistic Extraction vs Deterministic Governance</h2>
<p>The single most important conceptual difference among these three is how each handles the moment a fact changes. This is where &ldquo;memory&rdquo; stops being a storage problem and becomes a correctness problem.</p>
<p>Probabilistic extraction, as in Mem0, assumes the system can correctly decide that a new fact supersedes an old one by comparing semantics. When that match succeeds, the update is clean. When it fails — and it fails silently, without any user-visible error — both facts remain live. A knowledge base that says &ldquo;the API endpoint is at /v1&rdquo; and &ldquo;the API endpoint is at /v2&rdquo; at the same time is not a storage failure; it is a correctness hazard, because the LLM cannot disambiguate and may act on the deprecated value.</p>
<p>Zep improves on this by adding a temporal dimension. The <code>invalid_at</code> window means the system can represent &ldquo;this was true, and it stopped being true at this time.&rdquo; That is why Zep beats Mem0 on long-horizon benchmarks: when the agent is asked a question that spans time, it has the machinery to answer correctly.</p>
<p>ContextNest takes a different and stricter path. It does not try to reason about whether a fact is stale at query time. Instead, a human steward invalidates it at write time, and the system physically excludes it with deterministic <code>ctx forget</code>. There is no coexistence of old and new facts, because the old fact is removed from the retrievable set entirely. For anything where a wrong fact is expensive — pricing, legal, endpoints, compliance — this deterministic guarantee is the deciding factor.</p>
<h2 id="benchmark-reality-longmemeval-dmr-and-token-economics">Benchmark Reality: LongMemEval, DMR, and Token Economics</h2>
<p>Numbers matter when choosing memory infrastructure, but the numbers must be read in context. LongMemEval is the headline differentiator. Zep&rsquo;s 63.8% versus Mem0&rsquo;s 49.0% is a 15-point gap, and the research consensus attributes it to the temporal knowledge graph architecture beating flat vector RAG on long-horizon retention.</p>
<p>The DMR benchmark tells a similar story for Zep: 94.8% accuracy, and 98.2% when the retrieval is paired with GPT-4o Mini, setting state of the art. The practical implication is latency as well as accuracy — Zep advertises up to 90% response latency reduction versus stuffing full history into context.</p>
<p>Token economics are where the tools trade blows. Mem0 claims up to 80% prompt token reduction from chat-history compression. ContextNest claims a more aggressive ~100x cheaper session: roughly 500 tokens of pre-digested context instead of 50,000 tokens of raw files. Zep&rsquo;s wins are accuracy and latency rather than raw token count.</p>
<p>It is worth noting that ContextNest does not compete on LongMemEval, because it is not a semantic memory engine. Judging a governance vault by a retrieval-accuracy benchmark is like scoring a database migration tool on its transaction latency — the wrong measurement for the job. ContextNest&rsquo;s performance claims are about retrieval latency scaling (6ms to 841ms across 100 to 10,000 documents) and deterministic correctness, not semantic recall.</p>
<h2 id="how-to-stack-all-three-layers-in-one-production-agent">How to Stack All Three Layers in One Production Agent</h2>
<p>The practical payoff of this anatomy is the three-tier stack. Each layer handles one job, and together they optimize the context window:</p>
<ol>
<li><strong>Zep compresses sessions.</strong> Log the raw conversation, summarize it, and use the temporal graph to answer &ldquo;what happened and when.&rdquo; This keeps the conversation history from blowing up the context window.</li>
<li><strong>Mem0 injects the active preference.</strong> Pull only the current preference node for the user — their name, their preferred style, their active choices — and leave the rest out.</li>
<li><strong>ContextNest prunes unapproved directories.</strong> Feed the agent governed corporate knowledge through a native MCP server, with <code>ctx forget</code> deterministically excluding anything a steward has deprecated.</li>
</ol>
<p>The result is a context window that is simultaneously smaller and more trustworthy than any single layer alone. You are not choosing between session memory, personalization memory, and governed knowledge — you are composing them.</p>
<p>The integration path is cleanest with ContextNest because it speaks MCP natively, so it slots into Claude and Cursor with no middleware. Zep and Mem0 wrap their logic in custom SDKs or REST APIs, which means an additional network roundtrip and an extra abstraction layer between the agent and its memory.</p>
<h2 id="self-hosting-pricing-and-data-sovereignty-trade-offs">Self-Hosting, Pricing, and Data Sovereignty Trade-offs</h2>
<p>Hosting is where the three diverge most sharply on operational reality. ContextNest is uncompromisingly local-first: AGPL-3.0, self-hosted, Git-versioned markdown files, no vendor lock-in. If your company needs data to stay on its own infrastructure for regulatory or security reasons, ContextNest is the only one of the three that is genuinely designed for that from the ground up.</p>
<p>Zep is cloud-centric, and its deprecation of the Community Edition in April 2025 forced self-hosters onto raw Graphiti plus a graph database — a real operational commitment. Mem0 offers a hosted SDK model plus self-managed options, but its differentiating graph features are gated behind the $249/month Pro tier.</p>
<p>The cost profile follows the architecture. Mem0&rsquo;s hosted path has a recurring subscription. Zep&rsquo;s managed service has a subscription, and the self-hosted Graphiti route has infrastructure cost. ContextNest&rsquo;s self-hosted model has near-zero marginal cost per session, which is what makes the ~100x session economics so attractive at scale — you are not paying per token of remembered context.</p>
<h2 id="verdict-which-memory-layer-do-you-actually-need">Verdict: Which Memory Layer Do You Actually Need?</h2>
<p>There is no single winner in ContextNest vs Mem0 vs Zep, because they do not occupy the same slot. Choose based on what your agent actually forgets:</p>
<ul>
<li><strong>Choose Zep</strong> when your agent&rsquo;s problems are about time and long-horizon context — &ldquo;what did we discuss two weeks ago, and what changed since?&rdquo; Its temporal knowledge graph wins on LongMemEval and DMR, and it handles session memory best.</li>
<li><strong>Choose Mem0</strong> when you need broad personalization with the widest integration ecosystem and you can live with probabilistic extraction — 64,000 stars and up to 80% token reduction make it the default for conversational products that accept its stale-fact risk.</li>
<li><strong>Choose ContextNest</strong> when correctness and governance are non-negotiable — pricing, legal, compliance, or organizational knowledge where a stale fact is worse than no fact. Its deterministic, steward-approved, hash-chained vault is the only one of the three that can guarantee a deprecated fact is never retrieved.</li>
</ul>
<p>And in production, the honest answer is often all three. Session memory, personalization memory, and governed knowledge are three organs of one body. An agent with only one of them is missing most of its brain.</p>
<h2 id="faq">FAQ</h2>
<h3 id="what-is-the-difference-between-contextnest-mem0-and-zep">What is the difference between ContextNest, Mem0, and Zep?</h3>
<p>They solve different memory problems. Zep handles session log memory with a temporal knowledge graph, Mem0 extracts personalization preferences from conversation, and ContextNest governs corporate knowledge in a deterministic, self-hosted vault. They are complementary layers, not direct competitors.</p>
<h3 id="which-is-better-on-the-longmemeval-benchmark-zep-or-mem0">Which is better on the LongMemEval benchmark, Zep or Mem0?</h3>
<p>Zep scores 63.8% on LongMemEval versus Mem0&rsquo;s 49.0%, a 15-point gap driven by Zep&rsquo;s temporal knowledge graph. ContextNest is not benchmarked on LongMemEval because it is a governance vault rather than a semantic memory engine.</p>
<h3 id="why-does-contextnest-prevent-stale-fact-hallucinations-that-mem0-cannot">Why does ContextNest prevent stale-fact hallucinations that Mem0 cannot?</h3>
<p>Mem0 writes probabilistically, so when a semantic update match fails, old and new facts coexist and the LLM cannot disambiguate. ContextNest uses deterministic governance: a steward invalidates facts at write time and <code>ctx forget</code> physically excludes them, so a deprecated fact is never retrievable.</p>
<h3 id="is-contextnest-self-hostable-and-free">Is ContextNest self-hostable and free?</h3>
<p>Yes. ContextNest is AGPL-3.0, local-first, and self-hosted, storing governed context in Git-versioned markdown vaults verified with SHA-256 hash chains. There is no vendor lock-in, and it connects to Claude and Cursor natively as an MCP server.</p>
<h3 id="should-i-use-all-three-memory-frameworks-in-one-agent">Should I use all three memory frameworks in one agent?</h3>
<p>Often yes. Zep compresses session history, Mem0 injects only the active user preference, and ContextNest supplies governed corporate knowledge through a native MCP server. Stacking all three optimizes both the context window size and its trustworthiness.</p>
]]></content:encoded></item></channel></rss>