360 Secure SkillHub
360 安全技能中心

Memory Engine

该 Skill 为代理提供五层跨会话持久记忆:核心身份、档案事实、知识图谱、对话情节与行为反思,共 20 个工具;支持混合检索、去重、质量维护、导入导出、迁移和仪表盘,并可用定时任务自动整理。

ytangguo
ytangguo
热度 19.71
最近更新 2026-04-02 01:51:46
分类:知识依赖:代码执行 / 读写文件 / 第三方 API应用场景:笔记整理 / 摘要总结 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add openclaw-memory-engine
Metadata
name
memory-engine
description
MemGPT-style persistent memory — 20 tools for core identity, archival facts, knowledge graph, episodic recall, behavioral reflection, and data quality management. TRIGGER when: agent needs to remember something across sessions, recall past conversations, answer factual questions about the user, track behavioral patterns, manage conversation history, or maintain a knowledge graph of entity relationships. DO NOT TRIGGER for: in-session short-term context, file operations unrelated to memory, or tasks that don't involve persistence.
tags
["memory","memgpt","persistence","knowledge-graph","episodic","embeddings","recall","archival"]
requires
{"plugins":["@icex-labs/openclaw-memory-engine"]}

Memory Engine

MemGPT-style persistent memory for OpenClaw agents. Five-layer architecture with 20 tools.

Why

Agents wake up blank every session. Memory Engine fixes this with structured, searchable, self-maintaining memory that scales to tens of thousands of facts.

Architecture

Layer 1: Core Memory      → core.json (~500 tokens, always loaded)
Layer 2: Archival Memory   → archival.jsonl (unlimited facts, hybrid search)
Layer 3: Knowledge Graph   → graph.jsonl (entity relations, auto-extracted)
Layer 4: Episodic Memory   → episodes.jsonl (conversation summaries)
Layer 5: Reflective Memory → pattern analysis (topic trends, mood shifts)

Install

# Install the plugin (provides all 20 tools)
openclaw plugins install @icex-labs/openclaw-memory-engine

# Run setup (interactive: core memory, config, crons, legacy migration)
bash ~/.openclaw/extensions/memory-engine/setup.sh

# Restart gateway
openclaw gateway restart

Setup auto-detects existing MEMORY.md and daily logs, migrates them into archival, runs a quality pass (entity classification + importance scoring), and registers maintenance crons.

Tools (20)

Core Memory — Your Identity

  • core_memory_read — load identity block at session start
  • core_memory_replace — update a field by dot-path (auto-parses JSON strings)
  • core_memory_append — append to array fields (e.g., current_focus)

Archival Memory — Your Facts

  • archival_insert — store fact with entity + tags + importance (1-10). Auto-extracts graph triples.
  • archival_search — hybrid search: keyword (2×) + embedding (5×) + recency + access decay + importance
  • archival_update — correct an existing record
  • archival_delete — remove outdated facts
  • archival_stats — record count, entity/tag distribution, embedding coverage

Knowledge Graph — Your Relationships

  • graph_query — traverse entity relations with depth control
  • graph_add — manually add relation triples

Episodic Memory — Your Conversations

  • episode_save — save conversation summary with decisions, mood, topics
  • episode_recall — search past conversations by topic/keyword

Intelligence — Self-Improvement

  • memory_reflect — analyze behavioral patterns over configurable time window
  • archival_deduplicate — find/remove near-duplicates via embedding cosine similarity
  • memory_consolidate — extract structured facts from text blocks
  • memory_quality — re-classify entities, re-rate importance, extract missing graph triples

Backup & Admin

  • memory_export — full snapshot to JSON
  • memory_import — restore with merge or replace mode
  • memory_migrate — JSONL → SQLite with FTS5
  • memory_dashboard — generate browsable HTML dashboard

Search Scoring

Five-signal hybrid ranking:

Signal Weight Description
Keyword 2× Term match in content + entity + tags
Semantic 5× OpenAI text-embedding-3-small cosine similarity
Recency 0–1 Decays over 1 year
Access 0–0.5 Recently accessed records rank higher
Importance 0.5× Forgetting curve: importance × e^(-0.01 × days)

Falls back to keyword-only without OpenAI key. Cost: ~$0.001/session.

Multi-Agent

Each agent gets isolated memory based on its configured workspace. Uses ToolFactory pattern — resolved from session key at registration time. Privacy flag sharing: false for multi-user setups.

Self-Healing

  • Missing embeddings auto-backfilled on gateway restart (batch, rate-limited)
  • Legacy data auto-migrated during setup
  • Data quality auto-improved post-migration (entity + importance + graph)
  • Near-duplicates cleaned weekly by cron
  • Dashboard refreshed daily

Automated Maintenance

Schedule Job
Every 6h Consolidate daily logs into archival
Daily 9am Behavioral reflection + pattern analysis
Daily 9:30am Dashboard refresh
Weekly Sunday Deduplication pass

Platform Support

macOS (LaunchAgent), Linux (systemd timer), Windows (schtasks guided setup).

Links