360 Secure SkillHub
360 安全技能中心

Save/Load Context

为 OpenClaw 增加 /save 和 /load 斜杠命令,将会话中的 user 和 assistant 消息保存为本地 JSON,可按标签或索引列出、加载或删除保存内容,用于跨会话恢复上下文。保存文件位于 ~/.openclaw/saves/,并依赖 OpenClaw 与 Node.js 环境。

jkyotnfjfbjnknh
jkyotnfjfbjnknh
热度 43.56
最近更新 2026-05-11 17:38:19
分类:知识依赖:读写文件应用场景:笔记整理 / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add save-load
Metadata
name
save-load
description
Save and load OpenClaw conversation context with /save and /load slash commands
metadata
{"openclaw":{"requires":{"bins":["openclaw"]}}}

Save/Load Context Plugin

An OpenClaw plugin that adds /save and /load slash commands for persisting and restoring conversation context across sessions.

Problem

OpenClaw conversations are ephemeral — when you start a new session or reset, all context is lost. This plugin lets you save any conversation to disk and reload it later, preserving full context continuity.

Commands

Command Description
/save [label] Save the current conversation context with an optional label. If no label is provided, the save is named "unnamed".
/load List all previously saved conversation contexts with their labels, message counts, and save dates.
/load <name> Load a saved context by label or index number. This replaces the current session transcript with the saved conversation. After loading, the agent receives a system event with the save file path so it can restore full context.
/load --delete <name> Permanently delete a saved context file.

How It Works

Saving

  1. When /save is invoked, the plugin reads the session transcript (JSONL format)
  2. It identifies the conversation boundary — messages since the last /new, /reset, or /load
  3. Only user and assistant messages are extracted (tool calls and results are excluded)
  4. The messages are written to ~/.openclaw/saves/<timestamp>_<label>.json
  5. An index file (index.json) is updated for fast listing

Loading

  1. /load <name> finds the save file by label or index
  2. The saved messages are written as a new session transcript
  3. A system event is injected via enqueueSystemEvent() containing the save file path and message count
  4. The agent receives this event and can use the read tool to load the full context from the save file

Save File Format

{
  "version": 1,
  "label": "project-discussion",
  "savedAt": "2026-03-30T15:38:00+08:00",
  "messageCount": 42,
  "sourceSession": "telegram:2074807638",
  "messages": [
    { "role": "user", "content": "..." },
    { "role": "assistant", "content": "..." }
  ]
}

Installation

Via OpenClaw Plugin Manager

openclaw plugins install save-load

Manual Installation

  1. Copy the plugin directory to ~/.openclaw/extensions/save-load/
  2. Ensure openclaw.plugin.json and package.json are present
  3. Add "save-load" to the plugins.enabled array in ~/.openclaw/openclaw.json
  4. Restart the OpenClaw gateway: openclaw gateway restart

Storage

Save files are stored in ~/.openclaw/saves/. There is no limit on the number or size of saves — only disk space applies.

Requirements

  • OpenClaw 2026.3.30 or later
  • Node.js (included with OpenClaw)

Source Code

https://github.com/jkyotnfjfbjnknh/openclaw-save-load