session-memory
Use this skill when the user asks to remember yesterday’s (or a date’s) chat, to summarize a day’s sessions into memory, or to search past conversations (by keyword or date). It bridges session logs and the memory store so OpenClaw can answer “what did we talk about on …?” and use session context in replies.
When to use
- - User asks: “把昨天的聊天记到记忆里” / “总结一下 2 月 27 日的对话并写入 memory”
- User asks: “查一下之前我们说过关于 XXX 的对话” / “搜索会话里关于 discord/股票 的内容”
- User wants past chats to be searchable via memory/citations → run the summarize script for that day first, then normal memory search will include it.
Paths (default agent)
-
sessions.json = index;
<session-id>.jsonl = full transcript.
- Daily file:
memory/YYYY-MM-DD.md. Create or append a
## Session summary section.
Run scripts from the workspace root (e.g. ~/.openclaw/workspace), or pass --workspace so memory/ is resolved correctly.
1. Summarize a day’s sessions → memory (session-to-memory)
Writes a session summary for the given date into memory/YYYY-MM-DD.md (creates the file or appends a section). Memory citations and RAG will then include that day’s chat.
CODEBLOCK0
Optional:
- -
--date YYYY-MM-DD — date to summarize (default: yesterday in local time). - INLINECODE11 — workspace root; memory dir is
<workspace>/memory (default: cwd or ~/.openclaw/workspace). - INLINECODE14 — override sessions dir (default:
~/.openclaw/agents/main/sessions). - INLINECODE16 — append a “Session summary” section if the file exists; otherwise replace (default: append).
- INLINECODE17 — cap messages per session when building summary (default: 200).
Example:
CODEBLOCK1
Then answer the user with: “已把 2026-02-27 的会话摘要写入 memory/2026-02-27.md,之后你问当天的对话我就能通过记忆检索到。”
2. Search sessions (session-search)
Searches session JSONL by keyword and optional date range, returns snippets (session id, date, role, snippet) so the agent can use them in context. Does not write to memory; use this to answer “之前我们说过 XXX 吗?” or to gather context before summarizing.
CODEBLOCK2
Optional:
- -
--query "..." — search phrase (required). - INLINECODE19 — only sessions that started on or after this date.
- INLINECODE20 — only sessions that started on or before this date.
- INLINECODE21 — max number of snippets (default: 20).
- INLINECODE22 — override sessions dir.
Output: JSON array of { sessionId, date, role, snippet, timestamp } to stdout. Use the result in your reply or to decide whether to run session-to-memory for that day.
Example:
CODEBLOCK3
3. List sessions by date (for discovery)
To see which days have sessions (e.g. before summarizing or searching):
CODEBLOCK4
If jq is not available, use the session-search script with a very broad query and --limit 1 per day, or run the summarize script with --date for a specific date (it will report “no sessions” if none).
Tips
- - Summarize after the day ends (or when the user asks) so
memory/YYYY-MM-DD.md contains that day’s session summary; then OpenClaw’s memory/citation search will find it. - Session search is read-only over JSONL; it does not change memory. Use it to answer “有没有说过 XXX” or to prepare a summary.
- Large sessions are truncated by
--max-messages when summarizing to avoid huge memory files.
session-memory
当用户要求记住昨天的(或某个日期的)聊天记录、将一天的会话总结写入记忆,或搜索过去的对话(按关键词或日期)时,使用此技能。它连接了会话日志和记忆存储,使 OpenClaw 能够回答我们在……那天聊了什么?并在回复中使用会话上下文。
使用时机
- - 用户要求:把昨天的聊天记到记忆里/总结一下 2 月 27 日的对话并写入 memory
- 用户要求:查一下之前我们说过关于 XXX 的对话/搜索会话里关于 discord/股票 的内容
- 用户希望过去的聊天能通过记忆/引用被搜索到 → 先运行该日期的总结脚本,然后正常的记忆搜索就会包含它。
路径(默认代理)
- - 会话:~/.openclaw/agents/main/sessions/
- sessions.json = 索引;
.jsonl = 完整对话记录
- 每日文件:memory/YYYY-MM-DD.md。创建或追加一个## Session summary章节
从工作区根目录运行脚本(例如~/.openclaw/workspace),或传递--workspace参数以确保memory/路径正确解析。
1. 将一天的会话总结写入记忆(session-to-memory)
将指定日期的会话摘要写入memory/YYYY-MM-DD.md(创建文件或追加章节)。记忆引用和 RAG 随后将包含该日的聊天内容。
bash
node skills/session-memory/scripts/session-to-memory.js --date YYYY-MM-DD
可选参数:
- - --date YYYY-MM-DD — 要总结的日期(默认:本地时间的昨天)
- --workspace /path/to/workspace — 工作区根目录;记忆目录为/memory(默认:当前工作目录或~/.openclaw/workspace)
- --sessions-dir /path — 覆盖会话目录(默认:~/.openclaw/agents/main/sessions)
- --append — 如果文件已存在则追加Session summary章节;否则替换(默认:追加)
- --max-messages 200 — 构建摘要时每个会话的最大消息数(默认:200)
示例:
bash
cd ~/.openclaw/workspace
node skills/session-memory/scripts/session-to-memory.js --date 2026-02-27 --append
然后回复用户:已把 2026-02-27 的会话摘要写入 memory/2026-02-27.md,之后你问当天的对话我就能通过记忆检索到。
2. 搜索会话(session-search)
按关键词和可选的日期范围搜索会话 JSONL,返回片段(会话 ID、日期、角色、片段),供代理在上下文中使用。不会写入记忆;用于回答之前我们说过 XXX 吗?或在总结前收集上下文。
bash
node skills/session-memory/scripts/session-search.js --query 关键词 [--since YYYY-MM-DD] [--until YYYY-MM-DD] [--limit 20]
可选参数:
- - --query ... — 搜索短语(必填)
- --since YYYY-MM-DD — 仅搜索此日期或之后开始的会话
- --until YYYY-MM-DD — 仅搜索此日期或之前开始的会话
- --limit N — 最大片段数(默认:20)
- --sessions-dir /path — 覆盖会话目录
输出:JSON 数组{ sessionId, date, role, snippet, timestamp }到标准输出。在回复中使用结果,或决定是否对该日运行 session-to-memory。
示例:
bash
node skills/session-memory/scripts/session-search.js --query discord 断联 --since 2026-02-26 --limit 10
3. 按日期列出会话(用于发现)
查看哪些日期有会话(例如在总结或搜索前):
bash
for f in ~/.openclaw/agents/main/sessions/*.jsonl; do
[ -f $f ] && echo $(head -1 $f | jq -r .timestamp | cut -dT -f1) $(basename $f .jsonl)
done | sort -r
如果没有jq,可使用 session-search 脚本配合非常宽泛的查询和每日--limit 1,或对特定日期运行总结脚本(如果没有会话会报告no sessions)。
提示
- - 在一天结束后(或用户要求时)进行总结,这样memory/YYYY-MM-DD.md包含该日的会话摘要;之后 OpenClaw 的记忆/引用搜索就能找到它。
- 会话搜索是只读的,基于 JSONL;不会改变记忆。用于回答有没有说过 XXX或准备摘要。
- 总结时,大型会话会被--max-messages截断,以避免产生过大的记忆文件。