Scheduled tasks: add per-task session history retention limit

Resolved 💬 1 comment Opened Apr 13, 2026 by deffenda Closed May 24, 2026

Feature Request

Scheduled tasks (created via the schedule skill / mcp__scheduled-tasks__* tools) can run very frequently — e.g., twice per hour — and generate 30-50+ session history entries per day with no way to limit or auto-prune them.

Requested behavior

Each scheduled task definition should support a history_limit: N (or similar) field that:

  • Keeps only the N most recent session runs in the sidebar history
  • Automatically deletes older session artifacts (session-env/ directories and associated JSONL files) when the limit is exceeded

Current behavior

Session history grows unbounded. A task running every 30 minutes generates ~48 sessions/day. There is no way to configure retention or prune old sessions without manually deleting ~/.claude/session-env/ directories.

Workaround

Manually identify and delete orphaned ~/.claude/session-env/<uuid>/ directories (those without a corresponding ~/.claude/projects/**/<uuid>.jsonl) to remove stale scheduled-task sessions from the sidebar.

Impact

Users running multiple frequent scheduled tasks can accumulate 60+ sessions per day, making the session sidebar unusable.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗