360 Secure SkillHub
360 安全技能中心

memU: Persistent Memory for 24/7 Agents

该 Skill 封装 memU 持久化记忆框架,用 Resource、Memory Item、Memory Category 三层结构存储和检索跨会话信息,支持嵌入向量与 LLM 检索,并提供 Python 示例、OpenClaw 集成示例及可选的 pgvector 持久化方案。

projectsnowwork
projectsnowwork
热度 92.91
最近更新 2026-05-11 17:33:46
分类:知识依赖:代码执行 / 第三方 API / 内部调用大模型应用场景:笔记整理 / 研究 / 工作流

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add memu
Metadata
name
memu
description
Persistent memory infrastructure for 24/7 agents. Replaces flat-file memory with a three-layer architecture (Resource → Memory Item → Memory Category) that reduces token costs by 70-90% and enables proactive context retrieval. Built on NevaMind AI's open-source memU framework (v1.4.0). 92.09% accuracy on LoCoMo benchmark.
version
1.0.0
author
ProjectSnowWork
homepage
https://github.com/NevaMind-AI/memU
license
AGPL-3.0
tags
["agent-memory","long-term-context","proactive-agents","token-optimization","memory-infrastructure","pgvector"]
metadata
{"openclaw":{"requires":{"env":["OPENAI_API_KEY"],"bins":["python3"],"primaryEnv":"OPENAI_API_KEY"}}}

memU: Persistent Memory for 24/7 Agents

You are integrating memU, an open-source memory framework by NevaMind AI, into an agent that needs to remember, learn, and act proactively across long-running sessions.

When to Use This Skill

Use memU when the agent needs to:

  • Retain and retrieve information across sessions spanning days, weeks, or months
  • Reduce token costs from injecting raw conversation history into context (70-90% reduction)
  • Act proactively — surface relevant context before the user explicitly asks
  • Process multi-modal inputs (conversations, documents, images, logs) into structured memory
  • Distinguish between current and outdated information with temporal awareness

Do NOT use memU for:

  • Single-session chatbots that don't need persistence
  • Simple key-value storage (use a database directly)
  • Real-time streaming memory (not yet supported)

Core Concepts

memU organizes memory in three layers:

  1. Resources — Raw, immutable inputs (conversations, documents, images). The ground truth.
  2. Memory Items — Extracted atomic facts with timestamps, provenance, and confidence scores. Queryable and versioned.
  3. Memory Categories — Emergent clusters that self-organize as items accumulate. Enable broad context retrieval.

Two retrieval strategies are available:

  • Embedding (RAG) — Vector similarity search. Fast (50-150ms). Best for factual recall.
  • LLM — Deep semantic reasoning over memory files. Slower (500-2000ms). Best for nuanced, cross-category queries.

Installation

pip install memu-py

Optional persistent storage:

docker run -d --name memu-postgres \
  -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres \
  -e POSTGRES_DB=memu -p 5432:5432 pgvector/pgvector:pg16

Minimal Integration

import asyncio
from memu import MemoryService

service = MemoryService(
    llm_profiles={
        "default": {
            "provider": "openai",
            "base_url": "https://api.openai.com/v1",
            "api_key": "sk-your-key",
            "chat_model": "gpt-4o-mini",
            "embed_model": "text-embedding-3-small",
        }
    }
)

# Store
await service.memorize(
    resource_payload=[{"role": "user", "content": "I deploy on Tuesdays."}],
    modality="conversation",
)

# Retrieve
results = await service.retrieve(
    query=[{"role": "user", "content": "When should we deploy?"}],
    method="embedding",
)

Included Files

  • README.md — Full architecture explanation, 3 real-world scenarios, cost/performance tables, integration guides, troubleshooting
  • FAQ.md — 10 high-frequency questions with detailed answers
  • RELEASE.md — Release announcement
  • METADATA.yaml — ClawHub form metadata
  • examples/ — 4 complete, runnable Python scripts:
    • example_1_minimal.py — In-memory mode, no database
    • example_2_openclaw_integration.py — Replace OpenClaw default memory
    • example_3_production.py — Logging, retries, metrics
    • example_4_scenarios.py — Research assistant, email triage, system monitoring

Attribution

This is a community Skill packaging the official memU project by NevaMind AI. It does not modify or extend memU's code.