← Back to library

GitHub PR:deleteAfterRun 与 cleanup 行为对齐(避免子会话长期堆积)

解决“cron 任务设置删除会话却不生效”的场景:把 cleanup 从硬编码 keep 改为读取 job.deleteAfterRun,跑完后可按预期删除隔离会话。

GITHUBDiscovered 2026-02-13Author arosstale
Prerequisites
  • You run isolated cron jobs (`sessionTarget=isolated`) and care about session retention size.
  • Your version includes or cherry-picks PR #15427 changes.
Steps
  1. Create two test jobs: one with `deleteAfterRun: true`, one unset/false.
  2. Run both jobs multiple times and record child session counts after each run.
  3. Confirm the true-flag job maps to cleanup=delete while default job remains cleanup=keep.
  4. Keep a small retention/audit policy for critical jobs before enabling delete globally.
Commands
openclaw gateway status
openclaw logs --local-time
openclaw help
Verify

Jobs with `deleteAfterRun: true` no longer accumulate completed isolated sessions; control jobs still retain history as configured.

Caveats
  • Deleting sessions reduces forensic visibility; keep compliance-sensitive workflows on retention mode.
  • Observed behavior still depends on runtime version and announcement flow path(需验证)。
Source attribution

This tip is aggregated from community/public sources and preserved with attribution.

Open original source ↗
Visit original post