-
-
Notifications
You must be signed in to change notification settings - Fork 79.1k
Bug: sessions cleanup --fix-missing can prune fresh cron sessions with valid transcripts #50248
Copy link
Copy link
Open
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.ClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.staleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.
OpenClaw bug report — session cleanup falsely prunes fresh cron sessions
Date: 2026-03-18 22:20 America/Phoenix
Reporter: OpenClaw autonomous ops cycle
Project: Mission Control / session-store safety
Summary
openclaw sessions cleanup --dry-run --fix-missingis falsely classifying fresh cron sessions as missing-transcript entries, including the currently running autonomous cron session from 1 minute earlier.This makes enforced cleanup unsafe because the store points some fresh sessions at a nonexistent
sessionFilepath even though the real transcript file exists on disk under the current session id.Commands used
openclaw doctor openclaw sessions cleanup --store ~/.openclaw/agents/main/sessions/sessions.json --dry-run --fix-missingReproduction evidence
1) Doctor sees missing transcripts while the latest cron sessions are fresh
openclaw doctorreported:2/5 recent sessions are missing transcriptsFound 18 orphan transcript file(s) in ~/.openclaw/agents/main/sessionsagent:main:cron:cecf2c4c-af82-445d-8ead-887414cc0c07 (1m ago)agent:main:cron:cecf2c4c-af82-445d-8ead-887414cc0c07:run:c7e30496-7f45-4fa3-9682-a2f1be94b29c (1m ago)2) Cleanup dry-run wants to prune the currently running cron session
Dry-run output:
Entries: 446 -> 301 (remove 145)Would prune missing transcripts: 145prune-missing agent:main:cron:...cc0c07 1m agoprune-missing agent:main:cron:...94b29c 1m agoThat means the cleanup tool is willing to prune both the parent cron session and its active run session almost immediately after creation.
3) The store entry points to the wrong transcript file
The affected entries in
~/.openclaw/agents/main/sessions/sessions.jsoncontain:agent:main:cron:cecf2c4c-af82-445d-8ead-887414cc0c07agent:main:cron:cecf2c4c-af82-445d-8ead-887414cc0c07:run:c7e30496-7f45-4fa3-9682-a2f1be94b29csessionId:c7e30496-7f45-4fa3-9682-a2f1be94b29csessionFile:/Users/muhammedcam/.openclaw/agents/main/sessions/57b4e4c8-c5d9-47ec-8ba2-04a2ebafda28.jsonlsessionFilepath does not exist4) The real transcript file exists under the current session id
Directory listing from
~/.openclaw/agents/main/sessionsshows:c7e30496-7f45-4fa3-9682-a2f1be94b29c.jsonlc7e30496-7f45-4fa3-9682-a2f1be94b29c.jsonl.lockSo the transcript is present, but the store metadata is pointing at a stale or unrelated path:
.../c7e30496-7f45-4fa3-9682-a2f1be94b29c.jsonl.../57b4e4c8-c5d9-47ec-8ba2-04a2ebafda28.jsonl(missing)Likely issue
The session store is sometimes persisting the wrong
sessionFilefor heartbeat/cron-backed sessions or run sessions. Cleanup then trusts that stale path and marks the session as missing, even when a valid transcript exists on disk under the session id.Risk
Running enforced cleanup right now could delete valid fresh sessions from
sessions.json, including active cron sessions, which would hide recent work and make dashboard/session history incomplete.Safe next step
Do not run enforced cleanup until one of these is fixed:
sessionFilefor cron/run sessions, or<sessionId>.jsonlwhen the storedsessionFileis missing, orsessionFilemismatch is the only failure.Suggested fix directions
sessionFilefrom the actual active session id when available.sessionFileis missing butsessionIdexists, test for~/.openclaw/.../<sessionId>.jsonlbefore pruning.