360 Secure SkillHub
360 安全技能中心

Sayba Session Cleanup

该 Skill 用 Python 脚本修改 OpenClaw 的 sessions.json 索引,删除转录文件已丢失或全部的子代理会话条目,使其不再显示在侧边栏;支持预览、全量清理和指定代理,清理后需重启网关生效。

saybanet
saybanet
热度 30.09
最近更新 2026-05-11 17:46:49
分类:效率依赖:代码执行 / 读写文件应用场景:工作流 / 自动化脚本

安装技能

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

执行命令安装此 skill: npx secure-skills-cli add sayba-session-cleanup
Metadata
name
session-cleanup
description
Clean up stale or unwanted subagent sessions from OpenClaw webchat sidebar. Use when subagent sessions persist in the UI after completion, when the sidebar is cluttered with old subagent entries, or when the user asks to remove/clear/delete subagent sessions from the chat interface.

Session Cleanup

Remove stale subagent session entries from OpenClaw's sessions.json index so they disappear from the webchat sidebar.

When to Use

  • Subagent sessions remain visible in webchat sidebar after completion
  • User asks to "remove subagent", "clear subagent list", "delete subagent sessions"
  • Sidebar is cluttered with old subagent entries

How It Works

OpenClaw tracks sessions in ~/.openclaw/agents/<agent>/sessions/sessions.json. Subagent entries with missing transcript files are "ghost" sessions that still show in the UI. This skill removes those entries from the index.

Usage

Quick Clean (remove stale sessions only)

python3 scripts/cleanup_sessions.py

Removes subagent sessions whose transcript .jsonl files no longer exist on disk.

Remove ALL Subagent Sessions

python3 scripts/cleanup_sessions.py --all

Removes every subagent session entry regardless of transcript status.

Dry Run (preview only)

python3 scripts/cleanup_sessions.py --dry-run

Shows what would be removed without making changes.

Target Specific Agent

python3 scripts/cleanup_sessions.py --agent main

Only clean sessions for the main agent.

After Cleanup

Always restart the gateway for changes to take effect:

Use the gateway tool: action=restart

Or via CLI: openclaw gateway restart

Then refresh the webchat page.