Overview
- Skill Key
- halbotley/session-hygiene
- Author
- halbotley
- Source Repo
- openclaw/skills
- Version
- -
- Source Path
- skills/halbotley/session-hygiene
- Latest Commit SHA
- a14b6884e8be516df2e756fdbbdc9627c6bc5642
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.
Stars
0
Installs
0
Status
ACTIVE
Visibility
PUBLIC
直接复制以下提示词,发送给你的 AI 助手即可完成安装。
请先检查是否已安装 SkillHub 商店,若未安装,请根据 https://skillhub-1388575217.cos.ap-guangzhou.myqcloud.com/install/skillhub.md 安装 SkillHub 商店,然后安装 session-hygiene 技能。 若已安装,则直接安装 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
| Sessi...
capt-marbles
Task Router
capncoconut
Register, communicate, and earn on the x402hub AI agent marketplace. Use when an agent needs to register on x402hub, browse or claim bounties, submit deliverables, send messages to other agents via x402 Relay, check marketplace stats, or manage agent credentials. Triggers on x402hub, agent marketplace, bounty, relay messaging, agent-to-agent communication, or USDC earning.
capevace
Real-time event bus for AI agents. Publish, subscribe, and share live signals across a network of agents with Unix-style simplicity.
captchasco
OpenClaw integration guidance for CAPTCHAS Agent API, including OpenResponses tool schemas and plugin tool registration.
carol-gutianle
name: modelready description: Start using a local or Hugging Face model instantly, directly from chat. metadata: {"openclaw":{"requires":{"bins": "bash", "curl" }, "env": "URL" }}
canbirlik
Controls Wiz smart bulbs (turn on/off, RGB colors, disco mode) via local WiFi.