Session Cleanup for Openclaw

A utility for removing stale or ghost subagent sessions from the OpenClaw webchat sidebar to maintain a clean workspace.

saybanet
v1.0.0
Apr 30, 2026
0
627
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install sayba-session-cleanup

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install sayba-session-cleanup using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Session Cleanup?

The Session Cleanup skill is a specialized maintenance utility designed to manage the lifecycle of subagent sessions within the OpenClaw environment. Over time, the webchat sidebar can become cluttered with ghost sessions—entries that persist in the UI even after their underlying transcript files have been removed or the task is finished. This tool automates the process of pruning the session index, ensuring your interface remains relevant and high-performing.

Integrating Openclaw Skills like this one is critical for developers who manage multiple concurrent subagents. By targeting the sessions.json index, the skill allows for precise removal of specific agent entries or a complete purge of subagent history, which is essential for maintaining a focused development environment and avoiding UI lag caused by session bloat.

Session Cleanup Use Cases

  • Subagent sessions remain visible in the webchat sidebar after task completion.
  • The user explicitly asks to remove, clear, or delete specific subagent sessions.
  • The sidebar interface becomes cluttered with old or redundant subagent entries.
  • Cleaning up ghost sessions where transcript files no longer exist on disk.

How Session Cleanup Works

  1. The skill scans the sessions directory located at ~/.openclaw/agents//sessions/.
  2. It identifies session entries within the sessions.json index file.
  3. It cross-references these entries with the existence of corresponding .jsonl transcript files on the local disk.
  4. Entries without valid transcripts (or all subagents if the --all flag is used) are removed from the index.
  5. The skill provides a summary of removals or a preview in dry-run mode.
  6. A gateway restart is performed to reflect the updated index in the webchat UI.

Session Cleanup Setup

To utilize this feature among your Openclaw Skills, ensure you have the script available in your local agent directory and execute the following commands:

# Basic cleanup of stale sessions
python3 scripts/cleanup_sessions.py

# To preview changes without deleting
python3 scripts/cleanup_sessions.py --dry-run

After running the cleanup, you must restart the gateway for the UI to refresh:

openclaw gateway restart

Session Cleanup Data Schema & Taxonomy

The skill manages metadata within the OpenClaw directory structure to ensure UI synchronization.

Data Component Path / Detail
Session Index ~/.openclaw/agents/<agent>/sessions/sessions.json
Transcript Files Local .jsonl files stored in the agent's session directory
Target Filter Supports filtering by specific agent names via the --agent flag

Session Cleanup Advanced Features

  • Dry Run Mode: Safely preview which sessions will be removed before any changes are committed to the filesystem.
  • Bulk Purge: Remove every subagent session entry regardless of transcript status using the --all flag.
  • Targeted Cleaning: Specify a single agent to clean, preventing accidental deletion of sessions from other active agents.
  • CLI Efficiency: Designed to be run as a standalone script or integrated into automated maintenance pipelines for Openclaw Skills.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*