-
-
Notifications
You must be signed in to change notification settings - Fork 53k
Description
Feature Request
Version: 2026.2.6-3
Isolated cron jobs mint a fresh sessionId per run (as documented), but these session entries in sessions.json are never cleaned up:
deleteAfterRunonly deletes the job, not the session it created- The daily 4 AM reset only applies to channel sessions (DM/group), not cron-run sessions
- The docs acknowledge this gap: "when automating cleanup, delete individual keys"
With 23 cron jobs (some running every 15 minutes), that is 100+ orphan sessions per day. At scale this is a real problem — sessions.json grows unbounded.
Current Workaround
A user-managed cron job that periodically prunes stale cron:* keys from sessions.json directly, which works but feels like it should be built-in.
Proposed Solution
One or more of:
- Auto-TTL for cron sessions — configurable per-job
sessionTTL(e.g.,"sessionTTL": "1h"), after which the session entry is pruned automatically - Include cron sessions in the 4 AM daily reset (or a separate scheduled cleanup pass)
openclaw sessions prune --stale <duration>CLI command for manual/scripted cleanupsessions.cleanup.cronSessionTTLglobal config option (e.g., default 24h)
Option 1 (per-job TTL) gives the most control. Option 4 (global config) covers the common case with zero per-job config.
Impact
Every OpenClaw instance running isolated cron jobs accumulates dead sessions forever. The more cron jobs, the faster the growth. This affects sessions.json size, any tooling that enumerates sessions, and memory/disk over time.