Tools
Memclaw
The openclaw's memory context engine and plugin implementation of cortex memory
Install
npm install @memclaw/memclaw`
Configuration Example
{
"plugins": {
"entries": {
"memclaw": {
"enabled": true,
"config": {
"tenantId": "tenant_claw",
"autoStartServices": true,
"llmApiKey": "your-llm-api-key",
"llmModel": "gpt-5-mini",
"embeddingApiKey": "your-embedding-api-key",
"embeddingModel": "text-embedding-3-small"
}
}
},
"slots": {
// Optional: if you want to use Context Engine instead
// "contextEngine": "memclaw-context-engine"
}
},
"agents": {
"defaults": {
"memorySearch": { "enabled": false } // Disable OpenClaw built-in memory
}
}
}
README
<p align="center">
<img src="./assets/intro_banner_glance.webp">
</p>
<h1 align="center">MemClaw</h1>
<p align="center">
<a href="./README.md">English</a>
|
<a href="./README_zh.md">ไธญๆ</a>
</p>
<p align="center">
<a href="https://github.com/openclaw/openclaw"><img alt="OpenClaw Compatible" src="https://img.shields.io/badge/OpenClaw-compatible-brightgreen"/></a>
<a href="https://raw.githubusercontent.com/sopaco/cortex-mem/refs/heads/main/assets/benchmark/cortex_mem_vs_openclaw_3.png?raw=true"><img alt="Benchmark" src="https://img.shields.io/badge/Benchmark-Perfect-green?logo=speedtest&labelColor=%231150af&color=%2300b89f"></a>
<a href="https://github.com/sopaco/cortex-mem/tree/main/litho.docs/en"><img alt="Litho Docs" src="https://img.shields.io/badge/Litho-Docs-green?logo=Gitbook&color=%23008a60"/></a>
<a href="https://github.com/sopaco/cortex-mem/tree/main/litho.docs/zh"><img alt="Litho Docs" src="https://img.shields.io/badge/Litho-ไธญๆ-green?logo=Gitbook&color=%23008a60"/></a>
</p>
> **MemClaw** โ A [Cortex Memory](https://github.com/sopaco/cortex-mem) enhancement suite for OpenClaw, providing production-grade L0/L1/L2 layered semantic memory with native Context Engine integration.
---
## TL;DR
MemClaw seamlessly integrates [Cortex Memory](https://github.com/sopaco/cortex-mem)'s three-tier memory architecture into [OpenClaw](https://docs.openclaw.ai/zh-CN), enabling AI Agents to **automatically remember the past, proactively recall relevant memories, and browse the complete memory space on demand** โ all while achieving **up to 95% token savings** compared to OpenClaw's built-in memory solution.
| LoCoMo **#1** in memory recall capability | Slash token use by **90%** |
| :--- | :--- |
|  |  |
---
## Table of Contents
- [Why MemClaw](#why-memclaw)
- [Project Structure](#project-structure)
- [Core Features](#core-features)
- [Architecture Overview](#architecture-overview)
- [Three-Tier Memory Architecture](#three-tier-memory-architecture)
- [Quick Start](#quick-start)
- [Install Memory Plugin](#install-memory-plugin)
- [Install Context Engine](#install-context-engine)
- [Configuration Guide](#configuration-guide)
- [Available Tools](#available-tools)
- [Memory Plugin vs Context Engine โ Which Should I Choose](#memory-plugin-vs-context-engine--which-should-i-choose)
- [Relationship with Other Projects](#relationship-with-other-projects)
- [Performance Benchmarks](#performance-benchmarks)
- [Troubleshooting](#troubleshooting)
- [FAQ](#faq)
- [License](#license)
---
## Why MemClaw
OpenClaw is a powerful AI Agent gateway, but its built-in memory solution has the following limitations:
| Issue | OpenClaw Built-in Memory | MemClaw Solution |
|-------|--------------------------|------------------|
| Token Consumption | Loads complete history every time, ~15,982 tokens/query | Layered loading, ~2,900 tokens/query |
| Memory Accuracy | 35.65% (LoCoMo10) | **68.42%** |
| Multi-hop Reasoning | Weak | **84.29%** (Cat 4) |
| Memory Organization | Flat list | L0/L1/L2 structured hierarchy |
| Context Management | Built-in fixed strategy | Pluggable Context Engine |
MemClaw solves these problems โ transforming stateless Agents into intelligent assistants that can **remember user preferences, learn across sessions, and provide personalized interactions**.
---
## Project Structure
MemClaw consists of two independently installable OpenClaw plugins. Users can choose one or install both:
```
memclaw/
โโโ plugin/ # @memclaw/memclaw โ Memory Plugin (passive memory storage)
โ โโโ dist/ # Build artifacts
โ โโโ skills/ # Agent skill files (tool usage guides, best practices)
โ โโโ src/ # Source code
โ โโโ openclaw.plugin.json
โ โโโ README.md # Plugin detailed documentation
โ
โโโ context-engine/ # @memclaw/context-engine โ Context Engine (active context management)
โ โโโ dist/ # Build artifacts
โ โโโ index.ts # Plugin entry point
โ โโโ context-engine.ts # Context Engine lifecycle implementation
โ โโโ client.ts # Cortex Memory client
โ โโโ tools.ts # Tool definitions
โ โโโ config.ts # Configuration management
โ โโโ binaries.ts # Binary service management
โ โโโ TECH_DESIGN.md # Technical design document
โ
โโโ bin-darwin-arm64/ # macOS Apple Silicon pre-compiled binary package
โ โโโ bin/
โ โโโ qdrant # Qdrant vector database
โ โโโ cortex-mem-service # Cortex Memory REST API service
โ
โโโ bin-linux-x64/ # Linux x64 pre-compiled binary package (same structure)
โโโ bin-win-x64/ # Windows x64 pre-compiled binary package (same structure)
โ
โโโ LICENSE
```
### What Does Each Directory Do?
| Directory | NPM Package Name | Type | Purpose |
|-----------|------------------|------|---------|
| `plugin/` | `@memclaw/memclaw` | Memory Plugin (`kind: "memory"`) | Provides memory tools, requires Agent to actively call them |
| `context-engine/` | `@memclaw/context-engine` | Context Engine (`kind: "context-engine"`) | Automatically manages context, lifecycle hook driven |
| `bin-*/` | `@memclaw/bin-*` | Pre-compiled binary distribution | Qdrant + cortex-mem-service ready to use out of the box |
---
## Core Features
### Provided by Both Plugins
- **Three-Tier Memory Architecture** โ L0 abstract (~100 tokens) / L1 overview (~2000 tokens) / L2 full content, progressive disclosure
- **Semantic Vector Search** โ Vector similarity retrieval based on Qdrant, supports multi-layer weighted scoring
- **Automatic Service Management** โ Automatically starts Qdrant and cortex-mem-service when plugin launches, no manual ops required
- **One-Click Migration** โ Seamlessly migrate from OpenClaw native memory to MemClaw
- **Cross-Platform** โ Full coverage for Windows x64, macOS Apple Silicon, Linux x64
- **Zero External Dependency Installation** โ Qdrant and cortex-mem-service are pre-compiled and packaged, works with `npm install`
### Memory Plugin (`plugin/`) Exclusive
- **Manual Tool-Driven** โ Agent operates memory by calling tools like `cortex_search`, `cortex_add_memory`, `cortex_commit_session`, etc.
- **Fine-Grained Layer Control** โ Each search can specify which layers (L0/L1/L2) to return
- **Memory Filesystem Browsing** โ `cortex_ls` to browse `cortex://` URI space
### Context Engine (`context-engine/`) Exclusive
- **Fully Automatic Context Management** โ No need for Agent to call tools, automatically recalls relevant memories before each model run
- **Automatic Message Capture** โ Automatically writes each conversation turn to memory, triggers commit when threshold is reached
- **Smart Compression Takeover** โ `ownsCompaction: true`, fully controls context compression strategy
- **Archive Expansion** โ `cortex_archive_expand` tool to backtrack original conversations from compressed summaries
- **Bypass Mode** โ Configure `bypassSessionPatterns` to disable engine for specific sessions
---
## Architecture Overview
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ OpenClaw Gateway โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Memory Plugin โ โ Context Engine โ โ
โ โ (@memclaw/ โ โ (@memclaw/ โ โ
โ โ memclaw) โ โ context-engine) โ โ
โ โ โ โ โ โ
โ โ โข cortex_search โ โ โข ingest() โ message recv โ โ
โ โ โข cortex_recall โ โ โข assemble() โ ctx assembleโ โ
โ โ โข cortex_add_* โ โ โข afterTurn() โ write+commit โ
โ โ โข cortex_commit โ โ โข compact() โ compress+extract โ
โ โ โข cortex_ls โ โ โ โ
โ โ โข cortex_migrateโ โ + full toolset โ โ
โ โโโโโโโโโฌโโโโโโโโโโโ โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโ โ
โ โ โ โ
โ โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ cortex-mem-service (HTTP REST API, port 8085) โ โ
โ โ โ โ
โ โ POST /api/v2/sessions create session โ โ
โ โ POST /.../sessions/{id}/messages write message โ โ
โ โ POST /.../sessions/{id}/commit commit+extract โ โ
โ โ GET /.../sessions/{id}/context get context โ โ
โ โ POST /api/v2/search semantic search โ โ
โ โ GET /api/v2/filesystem/* virtual filesystemโ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Local FS โ โ Qdrant Vector DB โ โ
โ โ โ โ (port 6333/6334) โ โ
โ โ session/ โ โ โ โ
โ โ user/ โ โ Vector index + โ โ
โ โ agent/ โ โ semantic retrieval โ โ
โ โ resources/ โ โ โ โ
โ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
---
## Three-Tier Memory Architecture
MemClaw's core innovation is the L0/L1/L2 three-tier memory system, mimicking the progressive process of human memory from "vague impression" to "clear recollection":
| Layer | Filen
... (truncated)
tools
Comments
Sign in to leave a comment