Session回溯

v1.0.0

基于 OpenClaw 会话历史提取关键信息、查询关键词上下文,管理和回溯对话内容以辅助记忆和跟进。

0· 311·0 current·0 all-time
Security Scan
VirusTotalVirusTotal
Benign
View report →
OpenClawOpenClaw
Benign
medium confidence
Purpose & Capability
Name/description match the actions the SKILL.md describes: extracting key info from session history, searching keywords, and saving summaries to memory/*.md. The described use of sessions_list, sessions_history, read and write tools is coherent with this purpose.
!
Instruction Scope
The runtime instructions explicitly instruct reading JSONL session files under ~/.openclaw/agents/<agentId>/sessions/ and writing memory/YYYY-MM-DD.md. This is expected for a session-recall skill, but it grants access to potentially sensitive conversation history and instructs the agent to surface or persist that content. The SKILL.md also contains hard-coded example agentId/sessionId values (lin_xiaoman, a UUID) which could reflect another user's data or be confusing; the skill gives direct file paths and commands that, if executed, will access local user data.
Install Mechanism
No install spec and no code files: instruction-only skill. Nothing is downloaded or written to disk by an installer, which minimizes supply-chain risk.
Credentials
No environment variables, credentials, or config paths are declared beyond the local session file paths the skill needs to operate. The requested access (reading/writing session and memory files) is proportionate to the described functionality.
Persistence & Privilege
always is false and the skill is user-invocable. It does not request persistent or privileged platform-level presence. Its behavior (reading/writing local files) is limited to the agent's file area and memory files described in the instructions.
Assessment
This skill is internally consistent with its stated goal, but it instructs the agent to read and persist local conversation history, which can contain sensitive information. Before installing or using it: (1) Confirm you trust the agent and environment where it will run; (2) Verify that the sessions_list / sessions_history / read / write tools are safe and limited to the intended agent scope; (3) Remove or replace hard-coded example agentId/sessionId lines to avoid accidentally targeting another user's data; (4) Decide whether you want conversation excerpts to be written to memory/YYYY-MM-DD.md (these are persisted on disk); (5) If you have regulatory or privacy constraints, avoid enabling this skill or restrict its file access. If you want a stricter assessment, provide the runtime tool implementations (sessions_list/sessions_history/read/write) or details about filesystem permissions and where memory/ files are stored.

Like a lobster shell, security has layers — review code before you run it.

latestvk97e2qtq14hdh18bdtdp82dndn82a7v1memoryvk97e2qtq14hdh18bdtdp82dndn82a7v1openclawvk97e2qtq14hdh18bdtdp82dndn82a7v1recallvk97e2qtq14hdh18bdtdp82dndn82a7v1sessionvk97e2qtq14hdh18bdtdp82dndn82a7v1
311downloads
0stars
1versions
Updated 1mo ago
v1.0.0
MIT-0

Session 回溯技能

概述

Session 回溯技能,用于从 OpenClaw 的会话历史中提取信息、管理记忆和回溯对话。

功能

1. 提取关键信息写入 memory/YYYY-MM-DD.md

将 session 中的关键信息提取并保存到记忆文件中。

使用方式:

  • 调用 write 工具将内容写入 memory/YYYY-MM-DD.md 文件
  • 日期格式:当天日期,如 memory/2026-03-05.md

提取内容建议:

  • 对话中的重要决策
  • 关键信息点
  • 待办事项
  • 学习到的关于主人的信息

示例:

# 2026-03-05 记忆

## 重要信息
- 主人想要了解如何回溯 session
- 主人让我发布了一个飞书文档技能到 ClawHub

## 待办
- [ ] 创建 session 回溯 skill

## 对话摘要
今天主人问了关于 session 的问题...

2. 查询关键词在 session 中的出现次数/上下文

工具:

  • 使用 sessions_list 工具列出所有 session
  • 使用 sessions_history 工具获取特定 session 的历史
  • 使用 read 工具直接读取 JSONL 文件

方法:

方法一:使用 sessions_list

# 列出最近所有 session
sessions_list

方法二:使用 sessions_history

# 获取特定 session 的历史
sessions_history --sessionKey "agent:lin_xiaoman:feishu:direct:ou_xxx"

方法三:直接读取 JSONL 文件

# 读取 session 文件
# 路径格式:~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl

# 示例:查找关键词 "外卖"
# 使用 read 工具读取文件,然后分析内容

查找关键词的上下文:

  1. 使用 sessions_list 获取所有 session 的基本信息
  2. 根据 sessionKey 确定目标 session
  3. 使用 sessions_history 获取完整历史
  4. 在内容中搜索关键词并记录上下文

3. 回溯某段 session 并添加到当前对话

方式一:使用 sessions_history 工具

  1. 找到目标 session 的 sessionKey
  2. 使用 sessions_history 获取历史
  3. 将需要回溯的内容通过对话方式告诉模型

方式二:直接读取 JSONL 文件

  1. 确定 sessionId(可以从 sessions.json 或 sessions_list 获取)
  2. 读取 JSONL 文件:
    ~/.openclaw/agents/lin_xiaoman/sessions/<sessionId>.jsonl
    
  3. 提取需要的对话片段
  4. 将内容告诉用户或添加到当前上下文

重要提示:

  • 当前 session 的 sessionKey 格式:agent:lin_xiaoman:feishu:direct:ou_2545d3b430b99a135bdab87d5a09b68a
  • 当前 session 的 sessionId:3fefc0bb-b7e9-4736-b374-d1be9d12caec
  • JSONL 文件路径:~/.openclaw/agents/lin_xiaoman/sessions/3fefc0bb-b7e9-4736-b374-d1be9d12caec.jsonl

Session 文件位置

  • 索引文件:~/.openclaw/agents/<agentId>/sessions/sessions.json
  • 对话记录:~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl
  • 被 reset 的记录:~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl.reset.<时间戳>
  • 被删除的记录:~/.openclaw/agents/<agentId>/sessions/<sessionId>.jsonl.deleted.<时间戳>

使用示例

示例 1:查找今天关于"外卖"的对话

  1. 列出所有 session:

    sessions_list
    
  2. 获取当前飞书会话的历史:

    sessions_history --sessionKey "agent:lin_xiaoman:feishu:direct:ou_2545d3b430b99a135bdab87d5a09b68a"
    
  3. 分析内容,找到关于"外卖"的对话

示例 2:保存今天的重要对话到记忆

将今天的对话摘要写入 memory/2026-03-05.md

示例 3:回溯之前的某个 session

  1. 列出所有 session:sessions_list
  2. 找到目标 session 的 sessionKey
  3. 使用 sessions_history 获取历史
  4. 将需要的片段告诉用户

注意事项

  • 使用完 sessions_history 后,需要在回复中告诉用户找到的内容
  • JSONL 文件可以直接用 read 工具读取
  • 被 reset 的 session 文件后缀包含 .reset.
  • 被删除的 session 文件后缀包含 .deleted.

Comments

Loading comments...