-
-
Notifications
You must be signed in to change notification settings - Fork 69.2k
Sessions: orphan transcript .jsonl files accumulate in agents/main/sessions/ without cleanup #25373
Description
Summary
Orphaned transcript .jsonl files accumulate indefinitely in ~/.openclaw/agents/main/sessions/ because the session lifecycle does not clean up stale files when sessions are reset, restarted, or when subagent runs complete.
Observed Behavior
Running openclaw doctor reports:> Found 800 orphan transcript file(s) in ~/.openclaw/agents/main/sessions. They are not referenced by sessions.json and can consume disk over time.
sessions.json contains only the single live session entry (agent:main:main), while hundreds of .jsonl files from prior sessions remain on disk with no reference.
Root Cause (Hypothesis)
Each session reset (/reset, /new), gateway restart, or subagent run (sessions_spawn) creates a new UUID-named .jsonl file and updates the sessions.json pointer — but the previous file is never deleted. Subagent/cron run files appear to be written but never registered in sessions.json at all, so they are orphaned immediately after the run completes.
On a moderately active instance (~23 days uptime, multiple resets/day, frequent cron subagents), this produced 800 orphaned files.
Environment
- OpenClaw version:
2026.2.21-2(orphans accumulated before2026.2.23cleanup additions) - OS: Linux (LXC container, Proxmox)- Frequent subagent usage via
sessions_spawnand isolated cron jobs
Expected Behavior
Old .jsonl files should be deleted (or archived/rotated) when a session is reset or a subagent run completes. openclaw sessions cleanup (added in 2026.2.23) addresses future accumulation but must be run manually or scheduled — there's no automatic trigger.
Suggestions
- Auto-delete the previous
.jsonlon session reset/new - Auto-cleanup subagent transcript files after run completes (or after a configurable retention window)
- Optionally run cleanup on gateway start when orphan count exceeds a threshold
- Ship sensible defaults for
session.maintenance.maxDiskBytes/highWaterBytesso installations self-limit