openclaw - 💡(How to fix) Fix Add native sessions cleanup support for orphan/unindexed transcript archive/prune [1 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#77941Fetched 2026-05-06 06:18:59
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
2
Timeline (top)
commented ×1mentioned ×1subscribed ×1

Root Cause

Without native support, operators have to write ad hoc filesystem scripts for a session-lifecycle maintenance case that is adjacent to existing native session cleanup. That creates avoidable substrate drift and makes “live model pin” vs “orphan historical transcript” harder to distinguish.

RAW_BUFFERClick to expand / collapse

Problem

openclaw sessions cleanup currently supports --fix-missing, which removes session-store entries whose transcript files are missing. It does not appear to expose the inverse cleanup path: transcript files under ~/.openclaw/agents/<agentId>/sessions/*.jsonl that are no longer indexed by sessions.json.

This leaves historical/orphan transcript files discoverable by grep and lifecycle inventories even though they are not live session rows. In one production cleanup, 23 orphan/unindexed transcripts had historical anthropic/claude-sonnet-4-6 first-model entries. Native openclaw sessions --all-agents --json showed 0 indexed target rows and 0 Anthropic model/provider/override rows, but filesystem scans still flagged them as stale pins until manually quarantined.

Desired native behavior

Add a native, audited cleanup mode such as one of:

  • openclaw sessions cleanup --archive-orphans --all-agents --dry-run
  • openclaw sessions cleanup --prune-unindexed --all-agents --dry-run
  • openclaw sessions cleanup --orphan-transcripts --archive <dir> --all-agents

Required behavior:

  1. Enumerate configured/discovered agent session stores.
  2. Build the indexed transcript/sessionId set from sessions.json.
  3. Identify core transcript files not indexed by the store, excluding trajectory/checkpoint/deleted marker files.
  4. Dry-run prints exact file paths, agentId, sessionId, mtime, size, sha256.
  5. Enforce mode either archives to a supplied quarantine directory with manifest or prunes only with explicit confirmation flag.
  6. Never edits transcript JSONL content.
  7. Runs through the same Gateway/session-store safety model where applicable, or clearly marks filesystem-only archive semantics.

Why this matters

Without native support, operators have to write ad hoc filesystem scripts for a session-lifecycle maintenance case that is adjacent to existing native session cleanup. That creates avoidable substrate drift and makes “live model pin” vs “orphan historical transcript” harder to distinguish.

Evidence from production cleanup

  • OpenClaw version: 2026.5.3-1 (2eae30e).
  • Existing help surface checked:
    • openclaw sessions --help
    • openclaw sessions cleanup --help
  • Related available option: --fix-missing removes store entries whose transcript files are missing.
  • Missing option: no orphan/unindexed transcript archive/prune command.
  • Production finding:
    • 23 orphan/unindexed core transcripts with first model anthropic/claude-sonnet-4-6.
    • 0/23 appeared in openclaw sessions --all-agents --json.
    • 0 model/provider/override Anthropic rows in current session index.
    • 0 active file handles.
    • Manual quarantine required to clear filesystem-only stale detector signal.

extent analysis

TL;DR

Implement a native cleanup mode, such as openclaw sessions cleanup --prune-unindexed, to remove orphaned transcript files not indexed by the session store.

Guidance

  • Identify the required behavior for the native cleanup mode, including enumerating agent session stores, building the indexed transcript/sessionId set, and identifying core transcript files not indexed by the store.
  • Develop a dry-run feature to print exact file paths, agentId, sessionId, mtime, size, and sha256 before taking any action.
  • Implement an archive or prune option with explicit confirmation to ensure safe removal of orphaned transcripts.
  • Ensure the cleanup mode runs through the same Gateway/session-store safety model and does not edit transcript JSONL content.

Example

No code snippet is provided as the issue does not contain sufficient technical details to generate a specific example.

Notes

The proposed solution requires modifications to the openclaw sessions cleanup command to support the removal of orphaned transcript files. The exact implementation details may vary depending on the underlying architecture and requirements of the OpenClaw system.

Recommendation

Apply a workaround by implementing a native cleanup mode, such as openclaw sessions cleanup --prune-unindexed, to address the issue of orphaned transcript files. This approach ensures a safe and audited removal of unnecessary files, reducing substrate drift and improving the distinction between live model pins and orphan historical transcripts.

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 Add native sessions cleanup support for orphan/unindexed transcript archive/prune [1 comments, 2 participants]