Session Cleanup for Openclaw

An automated utility designed to evaluate, archive, and purge expired AI agent sessions based on custom value assessment rules.

xaiohuangningde
v1.0.0
Mar 1, 2026
0
1k
0

Install & Download

1. ClawHub CLI

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

npx clawhub@latest install 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 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?

Session Cleanup is a vital utility within the Openclaw Skills ecosystem that automates the maintenance of your AI agent's workspace. As agents operate, they generate significant amounts of session data, logs, and interaction histories that can clutter the system over time. This skill provides an intelligent solution by scanning specific directories, identifying stale data based on configurable expiration rules, and performing a value-based assessment before any deletion occurs.

By leveraging keyword-based evaluation, Session Cleanup distinguishes between routine logs and high-value insights, such as critical decisions or bug fixes. This ensures that while the system remains lean and fast, your agent's long-term memory is enriched with only the most relevant information. It is an essential tool for developers and power users who want to maintain high-performance Openclaw Skills without manual overhead.

Session Cleanup Use Cases

  • Automating the weekly removal of inactive Telegram interaction logs to save storage space.
  • Extracting and saving key debugging insights from sub-agent sessions into long-term memory before purging the logs.
  • Cleaning up message delivery queues for completed or failed tasks that are more than 24 hours old.
  • Managing the execution history of scheduled tasks by removing cron run logs older than three days.

How Session Cleanup Works

  1. Scans target directories including cron runs, delivery queues, and various agent-specific session folders.
  2. Identifies expired sessions by comparing the last activity timestamp against predefined thresholds (e.g., 7 days for sub-agents).
  3. Evaluates the content of expired sessions using a multi-category keyword matching system to determine its intellectual value.
  4. Archives sessions identified as valuable (containing decisions, fixes, or learning patterns) into the agent's memory.
  5. Purges low-value, expired data to recover disk space and maintain system organization.
  6. Generates a detailed cleanup report summarizing the number of sessions scanned, saved, and deleted.

Session Cleanup Setup

To deploy Session Cleanup within your environment, ensure you have the Openclaw Skills framework properly initialized. You can run the script manually or configure it as a recurring background task.

# Manual execution of the session cleanup script
~/.openclaw/workspace/skills/session-cleanup/cleanup.sh

# Configure a weekly cron job (Scheduled for every Sunday at 3:00 AM)
cron job add session-cleanup "0 3 * * 0" ~/.openclaw/workspace/skills/session-cleanup/run.sh

Session Cleanup Data Schema & Taxonomy

The skill manages data across several core directories with specific expiration logic as defined below:

Directory Description Expiration Rule
~/.openclaw/cron/runs/ Logs of scheduled task executions 3 Days
~/.openclaw/delivery-queue/ Finished or failed message queues 1 Day
~/.openclaw/telegram/ Telegram bot interaction history 7 Days
~/.openclaw/subagents/ Session data from spawned sub-agents 7 Days

Sessions are further categorized by keywords such as 'decision', 'important', 'fix', and 'learn' to determine archival priority.

Session Cleanup Advanced Features

  • Intelligent Value Assessment: Uses categorical keyword matching to prevent the loss of critical agent discoveries during cleanup.
  • Custom Expiry Thresholds: Supports different retention periods for different types of data, from 1-day queue logs to 7-day agent sessions.
  • Autonomous Memory Sync: Automatically pushes valuable session summaries into the agent's persistent memory bank.
  • Comprehensive Reporting: Produces a structured cleanup report to keep users informed of automated maintenance activities.
  • Multi-Agent Support: Capable of managing and cleaning up directories for multiple sub-agents simultaneously within the Openclaw Skills architecture.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*