Agent Memory Local
Overview
Search and explain facts from MEMORY.md and memory/*.md in a local workspace.
agent-memory-local gives an agent a transparent, local-first memory layer for questions like “我们上次怎么定这个规则的?” or “昨天为什么飞书断联?” without depending on a hosted memory service.
Production note: this retrieval style has already been used in real OpenClaw operating workflows behind jisuapi.com and jisuepc.com. That is a proof point, not a dependency.
Why install this
Use this skill when you want to:
- - find prior decisions, root causes, and preference history from Markdown memory files
- explain why a result matched instead of trusting a black-box memory API
- keep retrieval local and rebuild the index inside the workspace
Best fit:
- - local or self-hosted agent setups
- teams that store durable memory in Markdown
- users who want transparent, inspectable memory retrieval instead of a black-box cloud memory service
Common Use Cases
- - Decision recall — “我们之前怎么定这个规则的?”
- Incident review — “飞书昨天为什么断联了?”
- Change tracking — “更新后为什么记忆搜索变了?”
- Preference recall — “小红书配图策略现在怎么要求?”
- Policy / guardrail checks — “敏感信息能不能写进日志?”
Quick Start
30-second first run
CODEBLOCK0
Build the local index
CODEBLOCK1
Direct retrieval
CODEBLOCK2
Smart natural-language retrieval
CODEBLOCK3
Health check / doctor
CODEBLOCK4
Explain why a result matched
CODEBLOCK5
Not the best fit
Use a different memory system if you need:
- - graph/relationship-heavy enterprise memory
- multi-user hosted memory APIs
- fully managed temporal knowledge graph systems
Core Capabilities
1. Local index build
-
MEMORY.md
-
memory/learnings.md (if present)
-
memory/YYYY-MM-DD.md
- - Splits Markdown into retrieval chunks
- Builds a lightweight hashed vector index into
.memory-index/ under the workspace root - Stores freshness metadata for auto-rebuild checks
2. Explainable retrieval
Returns:
- - top matched file + title + snippet
- overlap count
- semantic score
- explain block with overlap terms / anchor hits / recency bonus
- index freshness status
- optional
explain view for cleaner public-facing reasoning output
This makes it useful when the user asks:
- - “我们上次怎么定这个规则的?”
- “昨天为什么飞书断联?”
- “记忆检索主路由是什么时候改的?”
- “关于这个需求之前有没有决定?”
3. Chinese-friendly anchors
The retriever is tuned for queries like:
- - INLINECODE8
- INLINECODE9
- INLINECODE10
- INLINECODE11
- INLINECODE12
- INLINECODE13
It boosts domain phrases, recency, and strong anchors instead of relying only on generic vector similarity.
4. Smart query rewriting
smart-query rewrites and scores multiple candidate queries automatically.
This helps with fuzzy questions like:
- - “昨天更新后为什么记忆搜索变了?”
- “飞书昨天为什么断联?”
- “主路由后来是不是改过?”
5. Optional rerank enhancement
If
SILICONFLOW_API_KEY is available, retrieval can optionally rerank the best candidates via SiliconFlow rerank.
If the key is missing, the skill still works locally.
Example Output
Example command:
CODEBLOCK6
Example result shape:
CODEBLOCK7
This is the point of the skill: not just “some memory results”, but a query rewrite + top hits + an explanation of why they matched.
Workflow
Workflow A — answer a memory question
- 1. Run INLINECODE16
- Inspect top 3-5 results and explain fields
- Open the source Markdown file if you need exact wording
- Answer with the retrieved fact, not with guesswork
Workflow B — prepare for long-running assistant memory
- 1. Keep durable facts in
MEMORY.md / INLINECODE18 - Run INLINECODE19
- Use
doctor to confirm index freshness - Use
query / smart-query as the workspace memory route
Workflow C — debug retrieval quality
- 1. Run INLINECODE23
- Confirm workspace detection and index freshness
- Rebuild with INLINECODE24
- Retry with INLINECODE25
- If results are fuzzy, try INLINECODE26
Configuration
Workspace resolution
The scripts resolve the workspace in this order:
- 1.
--workspace /path/to/workspace CLI arg - INLINECODE28 env var
- current working directory or its parents
- the skill location's parent chain
Optional env vars
- -
AGENT_MEMORY_WORKSPACE — force the workspace root - INLINECODE30 — disable/enable auto rebuild when stale
- INLINECODE31 — disable/enable rerank
- INLINECODE32 — enable rerank enhancement
Use --workspace when running outside the target repo and you want deterministic workspace selection.
Index location
The index is stored in
.memory-index/ at the resolved workspace root, not inside the skill folder.
Examples:
- - workspace
/repo/project → index at INLINECODE36 - workspace
E:/openclaw/.openclaw/workspace → index at INLINECODE38
When to rebuild the index
Rebuild manually when:
- 1. first run in a new workspace
- INLINECODE39 or
memory/*.md changed and you want immediate freshness - INLINECODE41 reports a stale index
- retrieval results look outdated or obviously off-topic
- you switched workspaces or restored memory files from backup
If MEMORY_AUTO_REBUILD=1, query flows may rebuild automatically when the index is stale.
Files in this skill
scripts/
- -
agent_memory_local.py — top-level CLI entrypoint - INLINECODE44 — builds INLINECODE45
- INLINECODE46 — direct retrieval engine
- INLINECODE47 — smart rewrite + best-query selector
- INLINECODE48 — health / freshness checker
- INLINECODE49 — cleaner explanation view for why results matched
- INLINECODE50 — regression benchmark runner against representative memory queries
- INLINECODE51 — workspace and path resolution helpers
references/
- -
architecture.md — design notes and tradeoffs - INLINECODE53 — packaging / release checklist for ClawHub
When to prefer this skill over heavier memory platforms
Use
agent-memory-local when you want:
- - local-first memory
- human-readable Markdown memory source of truth
- explainable retrieval
- low dependencies
- easy audits and backups
Prefer heavier systems (Mem0 / Letta / Graphiti / Zep-style approaches) when you need:
- - hosted memory APIs
- multi-user context services
- temporal knowledge graphs
- relationship-aware graph retrieval
- enterprise-scale memory orchestration
Agent Memory Local
概述
从本地工作区中的 MEMORY.md 和 memory/*.md 文件搜索并解释事实。
agent-memory-local 为智能体提供了一个透明、本地优先的记忆层,用于回答诸如 “我们上次怎么定这个规则的?” 或 “昨天为什么飞书断联?” 之类的问题,而无需依赖托管的记忆服务。
生产说明:这种检索方式已在 jisuapi.com 和 jisuepc.com 背后的真实 OpenClaw 运行工作流中使用。这是一个验证点,而非依赖项。
为什么安装此技能
在以下场景使用此技能:
- - 从 Markdown 记忆文件中查找先前的决策、根本原因和偏好历史
- 解释为什么某个结果匹配,而不是信任黑盒记忆 API
- 保持检索本地化,并在工作区内重建索引
最佳适用场景:
- - 本地或自托管智能体设置
- 将持久记忆存储在 Markdown 中的团队
- 希望透明、可检查的记忆检索,而非黑盒云记忆服务的用户
常见用例
- - 决策回顾 — “我们之前怎么定这个规则的?”
- 事件复盘 — “飞书昨天为什么断联了?”
- 变更追踪 — “更新后为什么记忆搜索变了?”
- 偏好回顾 — “小红书配图策略现在怎么要求?”
- 策略/护栏检查 — “敏感信息能不能写进日志?”
快速开始
30秒首次运行
bash
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py build-index
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py smart-query 飞书昨天为什么断联了 -k 3
构建本地索引
bash
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py build-index
直接检索
bash
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py query 昨天更新后为什么记忆搜索变了 -k 6
智能自然语言检索
bash
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py smart-query 飞书昨天为什么断联了 -k 6
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py smart-query What changed in our memory retrieval route after yesterdays update? -k 6
健康检查/诊断
bash
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py doctor
解释结果匹配原因
bash
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py explain 飞书昨天为什么断联了 --smart -k 3
python custom-skills/agent-memory-local/scripts/agent
memorylocal.py explain Why did Feishu disconnect yesterday? --smart -k 3
不适用场景
在以下需求时使用其他记忆系统:
- - 图/关系密集型企业记忆
- 多用户托管记忆 API
- 完全托管的时间知识图谱系统
核心能力
1. 本地索引构建
- MEMORY.md
- memory/learnings.md(如果存在)
- memory/YYYY-MM-DD.md
- - 将 Markdown 拆分为检索块
- 在工作区根目录下的 .memory-index/ 中构建轻量级哈希向量索引
- 存储新鲜度元数据,用于自动重建检查
2. 可解释检索
返回:
- - 最佳匹配文件 + 标题 + 片段
- 重叠计数
- 语义分数
- 包含重叠词/锚点命中/时效性加分的解释块
- 索引新鲜度状态
- 可选的 explain 视图,用于更清晰的面向公众的推理输出
这在用户询问以下问题时非常有用:
- - “我们上次怎么定这个规则的?”
- “昨天为什么飞书断联?”
- “记忆检索主路由是什么时候改的?”
- “关于这个需求之前有没有决定?”
3. 中文友好锚点
检索器针对以下查询进行了优化:
- - 飞书 掉线
- 记忆搜索 变了
- 主路由 默认入口
- 截图 宿主
- duplicate plugin id
- gateway timeout
它提升领域短语、时效性和强锚点的权重,而不是仅依赖通用向量相似度。
4. 智能查询重写
smart-query 自动重写并评分多个候选查询。
这有助于处理模糊问题,例如:
- - “昨天更新后为什么记忆搜索变了?”
- “飞书昨天为什么断联?”
- “主路由后来是不是改过?”
5. 可选重排序增强
如果 SILICONFLOW
APIKEY 可用,检索可以通过 SiliconFlow 重排序对最佳候选进行重排序。
如果密钥缺失,该技能仍可在本地工作。
示例输出
示例命令:
bash
python custom-skills/agent-memory-local/scripts/agentmemorylocal.py explain 飞书昨天为什么断联了 --smart -k 2
示例结果格式:
json
{
query: 飞书昨天为什么断联了,
used_query: 飞书 断联 duplicate plugin id gateway timeout,
results: [
{
rank: 1,
file: memory/2026-03-10-request-timed-out-before-a-res.md,
score: 0.5084,
why_matched: {
anchor_hits: [duplicate plugin id, gateway timeout, 断联, 飞书],
overlap_terms: [duplicate, duplicate plugin id, gateway, gateway timeout]
}
}
]
}
这就是该技能的核心价值:不仅仅是“一些记忆结果”,而是查询重写 + 最佳命中 + 匹配原因解释。
工作流
工作流 A — 回答记忆问题
- 1. 运行 smart-query
- 检查前 3-5 个结果和解释字段
- 如需精确措辞,打开源 Markdown 文件
- 使用检索到的事实回答,而非猜测
工作流 B — 为长期运行的助手记忆做准备
- 1. 将持久事实保存在 MEMORY.md / memory/*.md 中
- 运行 build-index
- 使用 doctor 确认索引新鲜度
- 使用 query / smart-query 作为工作区记忆路由
工作流 C — 调试检索质量
- 1. 运行 doctor
- 确认工作区检测和索引新鲜度
- 使用 build-index 重建
- 使用 query 重试
- 如果结果模糊,尝试 smart-query
配置
工作区解析
脚本按以下顺序解析工作区:
- 1. --workspace /path/to/workspace CLI 参数
- AGENTMEMORYWORKSPACE 环境变量
- 当前工作目录或其父目录
- 技能位置的父级链
可选环境变量
- - AGENTMEMORYWORKSPACE — 强制指定工作区根目录
- MEMORYAUTOREBUILD=0|1 — 禁用/启用索引过期时的自动重建
- MEMORYRERANK=0|1 — 禁用/启用重排序
- SILICONFLOWAPI_KEY — 启用重排序增强
在目标仓库外部运行且需要确定性工作区选择时,使用 --workspace。
索引位置
索引存储在解析后的工作区根目录下的 .memory-index/ 中,而非技能文件夹内。
示例:
- - 工作区 /repo/project → 索引位于 /repo/project/.memory-index/
- 工作区 E:/openclaw/.openclaw/workspace → 索引位于 E:/openclaw/.openclaw/workspace/.memory-index/
何时重建索引
在以下情况下手动重建:
- 1. 在新工作区首次运行
- MEMORY.md 或 memory/*.md 已更改,且需要立即更新
- doctor 报告索引过期
- 检索结果看起来过时或明显偏离主题
- 切换了工作区或从备份恢复了记忆文件
如果 MEMORYAUTOREBUILD=1,查询流程可能在索引过期时自动重建。
此技能包含的文件
scripts/
- - agentmemorylocal.py — 顶层 CLI 入口点
- buildindex.py — 构建 .memory-index/
- retrieve.py — 直接检索引擎
- memoryquery.py — 智能重写 + 最佳查询选择器
- doctor.py — 健康/新鲜度检查器
- explain.py —