openclaw - 💡(How to fix) Fix deleteAfterRun: true does not clean up isolated cron session files

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
RAW_BUFFERClick to expand / collapse

Bug Description

Setting deleteAfterRun: true on an isolated cron job does not delete the session .jsonl files after the run completes. Session files persist on disk indefinitely, causing disk bloat.

Environment

  • OpenClaw version: 2026.5.12
  • Node.js: 22.22.2
  • OS: Linux (Ubuntu)

Configuration

Cron job configured with:

  • sessionTarget: isolated
  • deleteAfterRun: true
  • payload.kind: agentTurn

Expected Behavior

When deleteAfterRun: true is set, the session file (agents/<agent>/sessions/<run-id>.jsonl) should be deleted after the cron run completes, regardless of success or failure.

Actual Behavior

Session files persist on disk. Example:

  • File: agents/main/sessions/8e53f40e-6eda-43b0-9f8d-e1e4e91b7029.jsonl
  • Size: 865K (230 messages)
  • Created: 2026-05-20 01:20 (cron run start)
  • Still exists: 2026-05-20 23:35 (22+ hours later)

The job had deleteAfterRun: true set, but the file was not cleaned up.

Additional Context

This affects isolated cron jobs that accumulate large contexts (e.g., daily reflection jobs with many tool calls). Without cleanup, sessions grow to 200+ messages, hit context overflow errors, and retry loops burn tokens.

A manual cleanup of agents/*/sessions/*.jsonl files older than 24 hours removed 765 files, indicating this is a systemic issue.

Related

  • The docs state: "Isolated jobs run a dedicated agent turn with a fresh session."
  • The deleteAfterRun flag appears in the cron job schema but may not be wired to session cleanup for isolated runs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix deleteAfterRun: true does not clean up isolated cron session files