M2Wise - Memory-to-Wisdom Engine
This is a skill for the OpenClaw AI Agent to enable long-term memory and self-evolving wisdom.
🎯 Purpose
As an AI agent, you inherently lack persistent memory across distinct sessions. The M2Wise skill bridges this gap. It allows you to:
- 1. Extract and store memories (facts, preferences, commitments) from user conversations.
- Retrieve contextual memories and aggregated wisdom before answering.
- Consolidate raw memories into overarching "Wisdom" (rules, schemas, and skills) during idle time.
🚦 When to Use This Skill
You should proactively invoke this skill in the following scenarios:
- - User expresses a preference: e.g., "I prefer short answers", "Don't use emojis."
- User shares a personal fact: e.g., "I work as a Python developer", "I live in Beijing."
- User asks you to remember: e.g., "Remember that I hate spam."
- Before answering complex questions: To recall the user's past preferences or facts to personalize your response.
🛠️ How to Use (Agent Instructions)
You can interact with M2Wise via its Python SDK. Use your shell/execution environment to run these scripts snippet by snippet.
1. Installation Requirements
Make sure the environment has M2Wise installed before calling its Python API:
CODEBLOCK0
2. Saving Memories (Online Phase)
When you detect a fact or preference in the conversation, run a quick python script to save it:
CODEBLOCK1
3. Retrieving Context (Online Phase)
Before fulfilling a user's request, fetch their relevant memories:
from m2wise_sdk import M2WiseSDK
sdk = M2WiseSDK()
context = sdk.get_context("current_user_id", "How should I answer this technical question?")
print("Retrieved Context:", context)
Action: Read the output of this script and adapt your final response to the user based on the retrieved context.
4. Background Processing (Sleep & Dream)
It is a good practice to trigger memory consolidation periodically (e.g., at the end of a long task).
CODEBLOCK3
🧩 MCP Server Alternative
If your OpenClaw runtime supports MCP (Model Context Protocol), you can start the M2Wise MCP server and use its native tools instead of writing Python scripts:
CODEBLOCK4
Available MCP Tools:
- -
m2wise_add: Add memory from conversation. - INLINECODE1 : Search memories and wisdom.
- INLINECODE2 : Generate wisdom drafts.
- INLINECODE3 : Verify and publish wisdom.
🧠 Memory and Wisdom Types You Will Encounter
- - Memories:
preference (likes/dislikes), fact (states/attributes), commitment (future actions). - Wisdoms:
principle (interaction guidelines), schema (behavioral patterns), skill (operational tactics).
🚀 Best Practices
- 1. Be Proactive: Don't wait for the user to explicitly say "remember this". If they state a strong preference, save it using
sdk.add_message(). - Context First: For ambiguous requests, always query the memory bank first.
- Consolidate Often: Run
trigger_sleep() and trigger_dream() after completing a major task to ensure your wisdom evolves and stays clean.
🔗 Resources
- - GitHub Repository: https://github.com/zengyi-thinking/M2Wise.git
- Installation via OpenClaw (ClawHub):
CODEBLOCK5
技能名称: m2wise
详细描述:
M2Wise - 记忆到智慧引擎
这是OpenClaw AI Agent的一项技能,用于实现长期记忆和自我进化的智慧。
🎯 目的
作为AI Agent,你天生缺乏跨会话的持久记忆。M2Wise技能弥补了这一差距。它允许你:
- 1. 提取并存储来自用户对话的记忆(事实、偏好、承诺)。
- 检索上下文记忆和聚合的智慧后再回答。
- 整合原始记忆为更高层次的智慧(规则、模式、技能)在空闲时间。
🚦 何时使用此技能
你应在以下场景主动调用此技能:
- - 用户表达偏好:例如,我喜欢简短的回答、不要使用表情符号。
- 用户分享个人事实:例如,我是一名Python开发者、我住在北京。
- 用户要求你记住:例如,记住我讨厌垃圾邮件。
- 在回答复杂问题之前:回忆用户过去的偏好或事实,以个性化你的回复。
🛠️ 如何使用(Agent指令)
你可以通过M2Wise的Python SDK与之交互。使用你的shell/执行环境逐段运行这些脚本。
1. 安装要求
在调用M2Wise的Python API之前,确保环境已安装M2Wise:
bash
pip install m2wise[all]
2. 保存记忆(在线阶段)
当你在对话中检测到事实或偏好时,运行一个快速的Python脚本来保存它:
python
from m2wise_sdk import M2WiseSDK
sdk = M2WiseSDK()
提取并保存用户的消息
sdk.add
message(currentuser_id, 对于技术问题,我更喜欢简洁的中文回答)
3. 检索上下文(在线阶段)
在满足用户请求之前,获取他们的相关记忆:
python
from m2wise_sdk import M2WiseSDK
sdk = M2WiseSDK()
context = sdk.getcontext(currentuser_id, 我应该如何回答这个技术问题?)
print(检索到的上下文:, context)
操作:读取此脚本的输出,并根据检索到的上下文调整你对用户的最终回复。
4. 后台处理(睡眠与梦境)
定期触发记忆整合是一个好习惯(例如,在完成一个长任务后)。
python
from m2wise_sdk import M2WiseSDK
sdk = M2WiseSDK()
睡眠:提取记忆并将其分组为智慧草稿
sdk.trigger
sleep(currentuser_id)
梦境:对照反例验证草稿并发布它们
sdk.trigger
dream(currentuser_id)
🧩 MCP服务器替代方案
如果你的OpenClaw运行时支持MCP(模型上下文协议),你可以启动M2Wise MCP服务器并使用其原生工具,而不是编写Python脚本:
bash
启动MCP服务器
m2wise-mcp --data-dir ./data
可用的MCP工具:
- - m2wiseadd:从对话中添加记忆。
- m2wisesearch:搜索记忆和智慧。
- m2wisesleep:生成智慧草稿。
- m2wisedream:验证并发布智慧。
🧠 你将遇到的记忆和智慧类型
- - 记忆:preference(喜好/厌恶)、fact(状态/属性)、commitment(未来行动)。
- 智慧:principle(交互指南)、schema(行为模式)、skill(操作策略)。
🚀 最佳实践
- 1. 主动出击:不要等待用户明确说记住这个。如果他们表达了强烈的偏好,使用sdk.addmessage()保存它。
- 上下文优先:对于模糊的请求,始终先查询记忆库。
- 经常整合:在完成一个主要任务后运行triggersleep()和trigger_dream(),确保你的智慧不断进化并保持清晰。
🔗 资源
- - GitHub仓库:https://github.com/zengyi-thinking/M2Wise.git
- 通过OpenClaw(ClawHub)安装:
bash
npx clawdhub@latest install m2wise