OpenClaw Plugin

Long-term memory
for OpenClaw agents

Replace the built-in memory backend with mem7's LLM-powered fact extraction, vector + graph dual-path recall, automatic deduplication, and Ebbinghaus forgetting curve.

openclaw plugins install @mem7ai/openclaw-mem7

What You Get

Drop-in memory upgrade for any OpenClaw agent. No code changes needed.

Auto-Recall

Before each agent turn, relevant memories are searched and injected into the system prompt automatically. The agent always has context.

Auto-Capture

After each turn, user + assistant messages are processed through LLM fact extraction. New facts are stored, duplicates are merged.

Graph Relations

Entities and relations are extracted and stored in a graph database. The agent sees both facts and connections.

Forgetting Curve

Enabled by default. Stale facts fade over time; frequently recalled memories grow stronger. No manual cleanup needed.

How It Works

Two lifecycle hooks and three tools — that's the entire integration surface.

1 User sends a message
OpenClaw agent receives the message and fires the before_prompt_build hook.
2 Auto-Recall
The plugin searches both the current session scope and the broader long-term scope, merges and deduplicates the top memories + graph relations, and injects them into the system prompt as <mem7_context>.
3 Agent responds
The LLM generates a response with full memory context. It can also call memory_search, memory_get, memory_list, memory_store, or memory_forget explicitly.
4 Auto-Capture
After the turn, the agent_end hook sends user + assistant messages through mem7's fact extraction pipeline. New facts stored, duplicates merged. Fire-and-forget — never blocks the response.

Injected Context Example

System prompt prepend
<mem7_context>
## Relevant memories about this user:
- [2026-03-15] Alice loves playing tennis (score: 0.92)
- [2026-03-10] Alice's coach is Sarah (score: 0.87)
- [2026-02-28] Alice is allergic to dairy (score: 0.74)

## Known relations:
- Alice -[loves_playing]-> tennis
- Alice -[coached_by]-> Sarah
- Alice -[allergic_to]-> dairy
</mem7_context>

Registered Tools

Five tools the agent can call explicitly, alongside the automatic hooks.

memory_search contract

Search session, long-term, or merged memory scopes for facts, preferences, and relations relevant to a query.

query string required
scope "session" | "long-term" | "all" default: all
limit integer default: 5
Returns scored memories + graph relations
memory_get contract

Retrieve a specific memory by UUID, or pass path="all" to list memories for the selected scope.

memoryId string preferred
path string legacy / "all"
Returns memory details or paginated list
memory_list custom

List stored memories for the selected session, long-term, or merged scope.

scope "session" | "long-term" | "all" default: all
limit integer default: topK / 50
Returns a scoped list of stored memories
memory_store custom

Explicitly store a fact into session or long-term memory. Processed through LLM extraction and dedup.

text string required
scope "session" | "long-term" default: long-term
Returns extraction actions (ADD / UPDATE / DELETE / NONE)
memory_forget custom

Delete a specific memory by UUID, or search for likely delete candidates by semantic query.

memoryId string optional
query string optional
Deletes directly or returns scored forget candidates

Configuration

Add the plugin to your ~/.openclaw/openclaw.json.

~/.openclaw/openclaw.json
{
  "plugins": {
    "slots": { "memory": "openclaw-mem7" },
    "entries": {
      "openclaw-mem7": {
        "enabled": true,
        "config": {
          "llm": {
            "base_url": "http://localhost:11434/v1",
            "api_key": "ollama",
            "model": "qwen2.5:7b"
          },
          "embedding": {
            "base_url": "http://localhost:11434/v1",
            "api_key": "ollama",
            "model": "mxbai-embed-large",
            "dims": 1024
          },
          "graph": { "provider": "flat" },
          "decay": { "enabled": true }
        }
      }
    }
  }
}

Config Reference

All fields except llm and embedding are optional.

Key Default Description
llm required LLM config for fact extraction and dedup (OpenAI-compatible)
embedding required Embedding provider config
vector { provider: "flat" } Vector store backend — flat (in-memory) or upstash
graph disabled Graph store — flat, neo4j, or kuzu
decay { enabled: true } Forgetting curve parameters (enabled by default in plugin)
autoRecall true Inject relevant memories before each agent turn
autoRecallLimit 5 Max memories to inject via auto-recall
topK 5 Default result limit for tool-driven search and list operations
searchThreshold unset Optional minimum score for plugin search and auto-recall
autoCapture true Extract and store facts after each agent turn
userId "default" Base user namespace for long-term memory; session scoping is derived separately
dbPath ~/.openclaw/mem7 Base directory for SQLite history DB and graph data

Architecture

The plugin sits between the OpenClaw agent runtime and the mem7 Rust engine.

OpenClaw Agent Runtime
User messages Tool calls Lifecycle hooks
openclaw-mem7 plugin
before_prompt_build before_agent_start agent_end memory_search memory_get memory_list memory_store memory_forget
mem7 Engine (Rust via napi-rs)
Vector Search Graph Search LLM Dedup Forgetting Curve Audit Trail

Design Decisions

Decay On by Default

Unlike standalone mem7, the plugin enables the forgetting curve by default. Long-running OpenClaw sessions accumulate stale facts quickly — decay keeps them fresh.

System Prompt Injection

Auto-recall injects via system prompt, not tool calls. This ensures every turn has context without relying on the agent to call memory_search explicitly.

Fire-and-Forget Capture

Auto-capture is fully async. Errors are logged but never block the user-facing response. Memory extraction happens in the background after each turn.

No File-Based Fallback

Unlike other OpenClaw memory plugins that use Markdown files, this plugin fully replaces the memory backend. No MEMORY.md is used.

Scoped Isolation

The base userId defaults to "default". The current sessionKey supplies session runId, and keys like agent:<id>:... also derive agentId for per-agent isolation.

Credential Resolution

If you omit API keys from the plugin config, it falls back to keys already configured in OpenClaw's model providers — no double-configuration needed.