OpenClaw Session Cleanup for Openclaw

A maintenance utility designed to optimize OpenClaw performance by purging accumulated subagent and cron job session records.

lrddrl
v1.0.1
Apr 10, 2026
0
600
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install openclaw-subagent-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 openclaw-subagent-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 OpenClaw Session Cleanup?

The OpenClaw Session Cleanup skill is an essential utility for maintaining the performance and responsiveness of the OpenClaw gateway. Every time a subagent is invoked or a cron job executes, a new entry is recorded in the sessions.json file. Over time, these entries can grow into the hundreds or thousands, significantly increasing the latency of starting new subagents from a few seconds to over ten seconds.

This tool specifically targets and removes transient child sessions, such as completed subagent tasks and cron run records, while carefully preserving critical data like main agent sessions, communication channel histories (WhatsApp, Telegram, etc.), and cron definitions. By compacting the sessions.json index, Openclaw Skills users can ensure their gateway remains lean and efficient.

OpenClaw Session Cleanup Use Cases

  • Resolving slow subagent startup times that exceed 10 seconds.
  • Reducing the file size of a bloated sessions.json file.
  • Performing routine maintenance to prevent gateway lag.
  • Clearing out old cron job execution records without deleting the schedule.
  • Managing disk space by optionally removing legacy .jsonl history files.

How OpenClaw Session Cleanup Works

  1. The user identifies a slowdown in the OpenClaw gateway performance.
  2. The OpenClaw gateway service is stopped to prevent file locking and data corruption.
  3. The cleanup script parses the sessions.json file and identifies entries based on their key structure.
  4. It filters out child sessions (subagents and cron runs) while retaining main and channel sessions.
  5. The script overwrites the sessions.json with the optimized dataset and optionally handles .jsonl history files.
  6. The gateway is restarted, now utilizing the compacted session index for faster lookups.

OpenClaw Session Cleanup Setup

To use this cleanup utility within your Openclaw Skills environment, follow these steps:

Step 1: Stop the Gateway

Ensure no sessions are active before running the cleanup.

openclaw gateway stop

Step 2: Execute Cleanup

Run the PowerShell script with your desired parameters.

# Standard cleanup (keeps .jsonl files)
.\cleanup.ps1

# Preview changes without applying them
.\cleanup.ps1 -DryRun

# Dangerous: Purge index AND delete conversation history files
.\cleanup.ps1 -CleanJsonl

Step 3: Restart

openclaw gateway

OpenClaw Session Cleanup Data Schema & Taxonomy

The skill manages data according to the following retention policy to protect Openclaw Skills integrity:

Session Type Key Pattern Action
Main & Channel Sessions agent:main:main, agent:main:<channel>:* Retained
Cron Definitions agent:main:cron:uuid Retained
Cron Run Records agent:main:cron:uuid:run:uuid Deleted
Subagent Sessions agent:main:subagent:uuid Deleted
Other Child Sessions agent:main:<type>:* Deleted

Note on .jsonl Files: By default, the complete conversation history stored in .jsonl format is preserved unless the -CleanJsonl flag is explicitly triggered.

OpenClaw Session Cleanup Advanced Features

  • DryRun Mode: Safely preview which sessions will be deleted before making permanent changes.
  • Granular File Management: Choose between cleaning just the session index or performing a full wipe of history files.
  • Channel Preservation: Automatically recognizes and protects communication metadata for platforms like Telegram, Signal, iMessage, and WhatsApp.
  • Automated Optimization: Can be integrated into maintenance scripts to keep Openclaw Skills running at peak performance.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*