返回顶部
s

session-hygiene

Prevent sessions.json bloat from accumulating isolated sessions (hooks, crons, subagents). Sets up a cron to archive stale sessions to daily JSONL files and keep sessions.json lean. Use when sessions.json grows large, the gateway becomes slow or unresponsive, or as preventive maintenance on any OpenClaw instance with hooks or crons. Related to openclaw/openclaw#15225.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
276
下载量
0
收藏
概述
安装方式
版本历史

session-hygiene

# Session Hygiene OpenClaw's session store (`sessions.json`) grows unbounded — every hook, cron, and subagent invocation creates a session entry that never gets cleaned up. Heavy setups (webhooks + crons) can hit 200MB+ and 7000+ sessions within weeks, causing gateway slowdowns and unresponsiveness. This skill sets up automated archive-and-rotate to keep `sessions.json` lean while preserving session history. ## Quick Setup Create a cron that runs every 6 hours: ```javascript cron(action: "add", job: { name: "Session Archive & Cleanup", schedule: { kind: "cron", expr: "0 */6 * * *", tz: "America/Los_Angeles" }, sessionTarget: "isolated", payload: { kind: "agentTurn", message: "Archive and clean up stale sessions. Run the script: python3 <skill-dir>/scripts/archive_sessions.py", timeoutSeconds: 60 }, delivery: { mode: "announce", channel: "slack" } }) ``` Adjust the timezone and delivery channel to match your setup. ## What It Does 1. **Archive**: Sessions older than 48 hours get moved to `sessions-archive/YYYY-MM-DD.jsonl` (one JSON line per session, grouped by date) 2. **Protect**: `agent:main:main` is never removed 3. **Rotate**: Archive files older than 30 days are deleted 4. **Report**: Logs how many sessions were archived, how many remain, and file sizes ## Manual Run For an immediate cleanup (e.g., if sessions.json is already bloated): ```bash python3 <skill-dir>/scripts/archive_sessions.py ``` Or for a one-time aggressive purge of sessions older than N hours: ```bash python3 <skill-dir>/scripts/archive_sessions.py --max-age-hours 1 ``` ## Tuning | Parameter | Default | Notes | |-----------|---------|-------| | `--max-age-hours` | 48 | How old a session must be before archiving | | `--archive-retention-days` | 30 | How long to keep archive JSONL files | | `--sessions-path` | Auto-detected | Path to sessions.json | | `--dry-run` | off | Preview what would be archived without changing anything | ## Sizing Estimates | Sessions/day | 48h retention | sessions.json size | |-------------|---------------|-------------------| | 50 | ~100 sessions | ~3MB | | 100 | ~200 sessions | ~6MB | | 200 | ~400 sessions | ~12MB | Without this skill, the same setup would grow to 200MB+ within a month.

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 session-hygiene-1776280533 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 session-hygiene-1776280533 技能

通过命令行安装

skillhub install session-hygiene-1776280533

下载 Zip 包

⬇ 下载 session-hygiene v1.0.0

文件大小: 3.68 KB | 发布时间: 2026-4-16 17:28

v1.0.0 最新 2026-4-16 17:28
Initial release: archive-and-rotate pattern for sessions.json bloat (openclaw/openclaw#15225)

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部