Noureddine RAMDI / graph-memory: a knowledge graph context engine plugin for AI agents using dual-path recall

Created Mon, 04 May 2026 10:23:02 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

adoresever/graph-memory

Every AI agent developer knows the struggle: managing context without drowning in token limits or losing track of past conversations. graph-memory tackles this head-on by building a knowledge graph from conversations and using a sophisticated dual-path recall system that combines entity-level precision with community-aware semantic matching. The result is a 75% compression of context size and recall ranked by Personalized PageRank computed in milliseconds.

What graph-memory is and how it works

graph-memory is a TypeScript plugin designed for OpenClaw, an AI agent platform. It serves as a Knowledge Graph Context Engine, addressing key pain points in AI agent memory such as context explosion, cross-session amnesia, and skill isolation.

Under the hood, graph-memory extracts structured triples from conversations, representing TASK, SKILL, and EVENT nodes connected by five specific edge types. This graph structure enables the system to maintain a rich, interconnected memory of the agent’s interactions.

The plugin uses SQLite as a persistent store, relying on prebuilt binaries for ease of installation and performance stability. It requires Node.js 22+ and OpenClaw v2026.3.x or newer. The data structure and algorithms allow compression of context size by roughly 75%, shrinking token counts from around 95,000 to under 24,000 at typical conversation lengths.

The standout architectural feature is the dual-path recall system. This combines precise entity-level search — perfect for retrieving exact facts or nodes — with generalized community-level semantic matching. This community detection groups related nodes, and the recall system ranks results using Personalized PageRank (PPR), a graph-based ranking algorithm. Remarkably, PPR computations occur in about 5 milliseconds even on thousands of nodes, enabling fast, contextually relevant recall.

Version 2.0 of graph-memory adds community-aware recall using LLM-generated community summaries, episodic context injection where snippets from the original conversation are attached to the top three ranked nodes, and universal embedding support compatible with any OpenAI-like endpoint.

What makes graph-memory’s approach technically interesting

Most AI agent memory solutions rely solely on vector embeddings and semantic similarity for recall. graph-memory goes beyond this by structuring memory as a graph of typed nodes and edges. This explicit knowledge graph enables more nuanced retrieval that respects relationships and task/skill/event distinctions.

The dual-path recall is the core technical strength. Precise entity-level search ensures factual accuracy and direct hits, while community-level semantic matching captures broader conceptual patterns and related context. Ranking these results with Personalized PageRank is clever — it leverages graph connectivity and node importance to order recall, rather than relying just on embedding distances or heuristic scores.

The tradeoff is increased complexity: building and maintaining a knowledge graph with typed edges requires careful design, and the system depends on OpenClaw’s infrastructure. Also, the SQLite backend, while reliable and simple, might not scale infinitely, but the 5ms ranking times indicate it’s performant for typical AI agent workloads.

The codebase is written in TypeScript, which fits well with OpenClaw’s ecosystem and Node.js runtime. The use of prebuilt SQLite drivers avoids common native compilation hassles, improving DX.

Finally, the 75% compression ratio is significant. Context explosion is a real bottleneck in LLM usage, and reducing token counts while retaining rich context is a practical win for anyone building complex AI agents.

Quick start

Windows one-click installer

v2.0 ships a Windows installer (.exe). Download from Releases:

  1. Download graph-memory-installer-win-x64.exe
  2. Run the installer — it auto-detects your OpenClaw installation
  3. The installer configures plugins.slots.contextEngine, adds the plugin entry, and restarts the gateway

Installation

Prerequisites

  • OpenClaw (v2026.3.x+)
  • Node.js 22+

Windows users

Download the installer from Releases:

graph-memory-installer-win-x64.exe

The installer handles everything: plugin installation, context engine activation, and gateway restart. After running, skip to Step 3: Configure LLM and Embedding.

Step 1: Install the plugin

Choose one of three methods:

Option A — From npm registry (recommended):

pnpm openclaw plugins install graph-memory

No node-gyp, no manual compilation. The SQLite driver (@photostructure/sqlite) ships prebuilt binaries — works with OpenClaw’s --ignore-scripts install.

Option B — From GitHub:

pnpm openclaw plugins install github:adoresever/graph-memory

Option C — From source (for development or custom modifications):

git clone https://github.com/adoresever/graph-memory.git
cd graph-memory
npm install
npx vitest run   # verify 80 tests pass
pnpm openclaw plugins install .

Step 2: Activate context engine

This is the critical step most people miss. graph-memory must be registered as the context engine, otherwise OpenClaw will only use it for recall but won’t ingest messages or extract knowledge.

Edit ~/.openclaw/openclaw.json and add plugins.slots:

{
  "plugins": {
    "slots": {
      "contextEngine": "graph-memory"
    },
    "entries": {
      "graph-memory": {
        "enabled": true
      }
    }
  }
}

Without this, the plugin registers but the ingest/assemble/compact pipeline never fires — you’ll see recall logs but zero data processed.

who should consider graph-memory

If you’re building AI agents on OpenClaw and face challenges with memory bloat, fragmented context, or isolated skills, graph-memory offers a pragmatic, well-engineered solution. Its knowledge graph approach and dual-path recall provide more structured and meaningful memory than simple vector search.

The tradeoff is setup complexity and dependency on OpenClaw and Node.js 22+. Also, the SQLite backend, while efficient, means scaling to extremely large knowledge graphs may require further optimization.

For developers needing a context engine that compresses token usage dramatically and supports rich semantic and factual recall, graph-memory is worth exploring. It’s particularly attractive if you want to mix exact entity retrieval with broader semantic patterns, ranked by a graph-based metric.

The code is surprisingly clean and well-tested (80 tests pass), and the Windows installer lowers the barrier to entry.

Overall, graph-memory fills a niche in AI agent memory management that goes beyond mere vector search, making it a solid tool for practitioners building long-lived, context-rich AI agents.


→ GitHub Repo: adoresever/graph-memory ⭐ 477 · TypeScript