返回顶部
m

memory-attention-router记忆注意力路由

Deterministic long-term memory routing for OpenClaw. Route, write, reflect on, and refresh reusable memory for multi-step agent work. Use when the task depends on prior sessions, durable user preferences, reusable procedures, past failures, project summaries, or stale memories that need replacement. Trigger on explicit memory phrases like "from now on", "remember this", "always", "prefer", "avoid", "my rule is", "replace my previous rule", and "going forward", and whenever an agent step needs a

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.1.0
安全检测
已通过
227
下载量
免费
免费
1
收藏
概述
安装方式
版本历史

memory-attention-router

记忆注意力路由技能

将长期记忆转化为一个紧凑的、具备角色感知的工作记忆数据包。

请勿将此技能用作简单的文档检索增强生成(RAG)。
请勿将原始记忆列表直接转储到模型上下文中。
应路由至正确的记忆区块,组合成一个紧凑的数据包,在出现更优证据时回写新学到的内容,并淘汰过时的记忆。

触发线索

当用户陈述一条持久性规则或要求保留/替换记忆时立即触发,尤其是包含以下短语的情况:

  • - 从现在开始
  • 记住这一点
  • 总是
  • 偏好
  • 避免
  • 我的规则是
  • 替换我之前的规则
  • 今后

当规划、执行、批评或响应步骤需要紧凑的记忆状态而非原始历史记录时,也应触发。

步骤角色

在读取记忆前,先选择当前步骤的角色:

  • - planner(规划者)
  • executor(执行者)
  • critic(批评者)
  • responder(响应者)

当前类型偏好:

  • - planner -> preference(偏好)、procedure(流程)、summary(摘要)
  • executor -> preference(偏好)、procedure(流程)、episode(片段)、reflection(反思)
  • critic -> reflection(反思)、preference(偏好)、summary(摘要)
  • responder -> preference(偏好)、summary(摘要)、procedure(流程)

重要含义:

  • - executor(执行者)应同时保留持久的硬约束和可复用的流程

读取流程

  1. 1. 构建路由请求,包含:
- goal(目标) - step_role(步骤角色) - session_id(会话ID,如已知) - task_id(任务ID,如已知) - user_constraints(用户约束) - recent_failures(近期失败) - unresolved_questions(未解决问题)
  1. 2. 运行:
python3 {baseDir}/scripts/memory_router.py route --input-json
  1. 3. 读取packet(数据包)。
  2. 在下游推理中使用该数据包。
  3. 当需要了解某个记忆为何被选中时,检查debug.selectedblocks和debug.selectedmemories。

路由器采用确定性的两阶段流程:

  1. 1. 从taskscoped(任务范围)、sessionscoped(会话范围)、durableglobal(持久全局)和recentfallback(近期回退)中选择最佳区块
  2. 仅对所选区块内的记忆进行评分

写入流程

在重要结果产生后存储记忆:

python3 {baseDir}/scripts/memory_router.py add --input-json

在以下情况写入记忆:

  • - 学习到持久的用户偏好或规则时
  • 可复用的流程变得清晰时
  • 某个工具结果将在后续产生影响时
  • 某种失败模式应影响未来行为时
  • 某个稳定的摘要值得保留时

如果新记忆替换了旧记忆,请包含replacesmemoryid。路由器将淘汰旧记忆,将其向前链接到替换记忆,并持久化淘汰原因。

反思流程

在完成有意义的工作后或在一组失败之后,创建反思记忆,并可选择创建流程记忆:

python3 {baseDir}/scripts/memory_router.py reflect --input-json

反思用于:

  • - 经验教训
  • 警告
  • 失败模式
  • 从成功工作中衍生出的可复用流程

刷新流程

当新证据使旧记忆失效或需要替换时:

python3 {baseDir}/scripts/memory_router.py refresh --input-json

刷新用于:

  • - 停用过时记忆
  • 使用replacementmemoryid标记替换关系
  • 使用refresh_reason持久化记忆被淘汰的原因
  • 当存在替换记忆时创建矛盾链接

数据包规则

一个好的数据包包含:

  • - hardconstraints(硬约束)
  • relevantfacts(相关事实)
  • procedurestofollow(待遵循流程)
  • pitfallstoavoid(待避免陷阱)
  • openquestions(开放问题)
  • selectedmemory_ids(选中的记忆ID)

当前紧凑性目标:

  • - selectedmemoryids -> 上限5个
  • hardconstraints -> 上限4个
  • relevantfacts -> 上限3个
  • procedurestofollow -> 上限3个
  • pitfallstoavoid -> 上限3个
  • open_questions -> 上限5个

优先选择紧凑、高信号的数据包,而非宽泛的召回。

路由规则

  • - 优先选择持久、可复用的记忆,而非嘈杂的临时笔记。
  • 为执行步骤保留硬约束,而不仅仅是规划步骤。
  • 使用support(支持)边帮助经过验证的记忆在排名决策中胜出。
  • 方向性地处理contradicts(矛盾)边:惩罚过时的目标,而非断言矛盾的新记忆。
  • 当摘要和冗长的原始历史携带相同信号时,使用摘要而非原始历史。
  • 当替换关系明确时淘汰过时记忆;不允许冲突的活跃记忆无限累积。

初始化

初始化数据库:

python3 {baseDir}/scripts/memory_router.py init

默认数据库路径行为:

  • - 如果设置了MARDBPATH,则使用该路径
  • 否则,当安装在/skills/memory-attention-router时,默认路径为/.openclaw-memory-router.sqlite3

检查已存储的记忆:

python3 {baseDir}/scripts/memory_router.py list --limit 20

检查单条记忆:

python3 {baseDir}/scripts/memory_router.py inspect --memory-id

文件指南

参见:

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 memory-attention-router-1776373744 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 memory-attention-router-1776373744 技能

通过命令行安装

skillhub install memory-attention-router-1776373744

下载

⬇ 下载 memory-attention-router v1.1.0(免费)

文件大小: 25.43 KB | 发布时间: 2026-4-17 15:22

v1.1.0 最新 2026-4-17 15:22
- Improved SKILL.md for clarity and conciseness, with updated descriptions and trigger cues.
- Added new trigger phrases like "replace my previous rule" and guidance on when to trigger for agent steps.
- Clarified that executor steps should preserve hard constraints alongside reusable procedures.
- Defined stricter caps for packet sizes to ensure compact, high-signal working-memory packets.
- Expanded routing rules, including use of support/contradicts edges and priority for durable, reusable memories.
- Refined write, reflect, and refresh flow instructions for better memory lifecycle management.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部