openclaw-session-cleanup

Clean up accumulated subagent and cron:run child sessions in OpenClaw to fix slow subagent startup. Use when: subagents are slow to start, sessions.json is too large, too many child sessions have accumulated, session cleanup is needed, or the user mentions "session cleanup", "session compact", "clean sessions", "subagent slow", "sessions.json too large", "child session accumulation", "session too many", "subagent startup slow", "gateway slow". 清理 OpenClaw 积累的 subagent 和 cron:run child sessions,解决 subagent 启动慢的问题。 当用户提到 subagent 启动慢、session 太多、想清理 sessions、sessions.json 太大、child session 积累时,务必使用此 skill。

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "openclaw-session-cleanup" with this command: npx skills add lrddrl/openclaw-session-cleanup-ruodon

keywords:

  • session cleanup
  • subagent slow
  • sessions.json too large
  • child session accumulation
  • session compact
  • clean sessions
  • subagent startup slow
  • gateway slow
  • session too many
  • 清理 session
  • subagent 启动慢
  • sessions.json 太大

OpenClaw Session Cleanup

Background / 背景

Every subagent call and cron job execution leaves an entry in sessions.json. After a few days of use, hundreds of entries accumulate, causing the gateway to slow down when starting new subagents.

Symptom: Subagent startup goes from a few seconds to 10+ seconds. Root cause: Completed child session entries piling up in sessions.json. Fix: Remove subagent and cron:run child session records, keep main and channel sessions.

每次 subagent 调用和 cron job 执行都会在 sessions.json 中留下记录。积累几百条后,gateway 启动 subagent 时明显变慢。

症状: subagent 启动时间从几秒变成十几秒甚至更长。 根因: sessions.json 中积累了大量已完成的 child session 索引。 解法: 删除 subagent 和 cron:run 类型的 child session 记录,保留主 session 和 channel session。


Steps / 操作步骤

Step 1: Stop Gateway

openclaw gateway stop

Step 2: Run cleanup script

.\cleanup.ps1             # 清理 sessions.json 索引(默认保留 .jsonl 文件)
.\cleanup.ps1 -DryRun     # 预览模式,不实际修改
.\cleanup.ps1 -KeepJsonl  # 保留 .jsonl history 文件(明确指定,不删)
.\cleanup.ps1 -CleanJsonl # 危险!同时删除 .jsonl 文件(对话历史会丢失)

Step 3: Restart Gateway

openclaw gateway

What is kept / 保留规则

Session typeExample keyAction
Main sessionagent:main:main✅ Keep
WhatsAppagent:main:whatsapp:direct:+1xxx✅ Keep
Telegramagent:main:telegram:direct:xxx✅ Keep
Signalagent:main:signal:direct:+1xxx✅ Keep
Google Chatagent:main:google chat:direct:xxx✅ Keep
Lineagent:main:line:direct:xxx✅ Keep
WeChatagent:main:wechat:direct:xxx✅ Keep
iMessage / SMSagent:main:imessage:direct:xxx✅ Keep
BlueBubbles (iOS)agent:main:bluebubbles:direct:xxx✅ Keep
其他 channel sessionagent:main:<channel>:...✅ Keep
Cron definitionagent:main:cron:uuid✅ Keep
Cron run recordagent:main:cron:uuid:run:uuid❌ Delete
Subagent sessionagent:main:subagent:uuid❌ Delete
其他 child sessionagent:main:<type>:...❌ Delete

⚠️ 关于 .jsonl 文件(对话历史)

默认不删除 .jsonl 文件。 .jsonl 包含完整的对话历史,删除后无法恢复。 如需清理 .jsonl,必须加 -CleanJsonl 参数:

.\cleanup.ps1 -CleanJsonl    # 清理 sessions.json 索引 + 删除 .jsonl 文件

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

Windows应用控制器

Windows应用控制器 - 原创技能。让AI通过自动化技术控制Windows应用程序,包括打开/关闭应用、点击按钮、填写表单、截取屏幕等操作。适用于GUI自动化、测试、数据录入等场景。

Registry SourceRecently Updated
Automation

x0x

Secure computer-to-computer networking for AI agents — gossip broadcast, direct messaging, CRDTs, group encryption. Post-quantum encrypted, NAT-traversing. E...

Registry SourceRecently Updated
Automation

clear-skills

This skill should be used when the user wants to clear, remove, or clean up AI agent rules, skills, or instruction files from their coding environment. It su...

Registry SourceRecently Updated
Automation

AI Remove Watermark

Remove watermarks from images through the Airemovewatermark API. Use when an agent needs to remove a watermark from a local image file or remote image URL, p...

Registry SourceRecently Updated
1671isees