Skip to content

Session files should never be deleted — rename .deleted.* to .archived.* #56609

@siraustin

Description

@siraustin

Problem

When a user runs /new or /reset, OpenClaw renames session .jsonl files to .jsonl.deleted.* or .jsonl.reset.*. The word "deleted" in the filename creates the mental model that these files are disposable. They're not — they're the only record of entire conversations.

Downstream tools (backup scripts, migration scripts, LCM backfill tooling) inherit this attitude and treat these as cleanup candidates. This led to irreversible data loss in a real deployment — 92 founding-era session transcripts were staged in /tmp/ during an LCM backfill, and when the machine rebooted, the only copies were gone.

Proposal

  1. Rename the convention: .archived.* instead of .deleted.* (and .archived-reset.* instead of .reset.*)
  2. Or better: move archived sessions to a dedicated sessions/archive/ subdirectory instead of renaming in place
  3. Never rm a session file in any OC codepath — only move/rename
  4. Consider a sessions/archive/ directory that's clearly a permanent store, not a trash bin

Why This Matters

  • Session .jsonl files are small (text), cheap to store, and irreplaceable
  • They're the only way to reprocess/recompact if LCM or any future context system needs to re-ingest
  • The naming convention is the root cause — if the files were called .archived.*, nobody downstream would treat them as disposable
  • Worst case, users can gzip old sessions — but they should never be deleted

Current Behavior

# /new creates:
session-uuid.jsonl.deleted.2026-03-26T22-05-08.451Z

# /reset creates:  
session-uuid.jsonl.reset.2026-03-26T21-29-41.201Z

Proposed Behavior

# Option A: rename convention
session-uuid.jsonl.archived.2026-03-26T22-05-08.451Z

# Option B: move to archive dir (preferred)
sessions/archive/session-uuid.jsonl

Filed from real-world data loss. The naming created the permission to be careless.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:needs-product-decisionClawSweeper marked this issue as needing a product or behavior decision.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.impact:session-stateSession, 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.staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions