Skip to content

Isolated cron sessions accumulate indefinitely — no built-in pruning #12289

@kurthamm

Description

@kurthamm

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:

  • deleteAfterRun only 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:

  1. Auto-TTL for cron sessions — configurable per-job sessionTTL (e.g., "sessionTTL": "1h"), after which the session entry is pruned automatically
  2. Include cron sessions in the 4 AM daily reset (or a separate scheduled cleanup pass)
  3. openclaw sessions prune --stale <duration> CLI command for manual/scripted cleanup
  4. sessions.cleanup.cronSessionTTL global 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions