Skip to content

[Feature]: Script to restore session history archived by new daily-reset mechanism (introduced v2026.2+) #45003

@CadanHu

Description

@CadanHu

Summary

A utility script to automatically restore and re-index session transcript files
that were archived as .reset.<timestamp> by the new daily session-reset mechanism.

Problem to solve

Starting with PR #14949 (Feb 13, 2026) and PR #35493 (Mar 6, 2026), OpenClaw
began archiving old transcript files as <session>.jsonl.reset.<timestamp> when
a session resets — both on manual /new//reset and on the scheduled daily
reset (default: 4 AM).

Users who upgraded to v2026.3.12 (the first release containing both changes)
found that all their session history had disappeared from the UI sidebar.
This happened because the daily reset ran for the first time after upgrade and
archived all existing sessions at once — not because of a migration script.

The data is not lost; it exists in .reset.* archive files. But re-indexing
dozens of files manually is tedious.

Proposed solution

A script that automates the restoration: it renames .reset.* archive files
back to .jsonl and rebuilds the sessions.json index.

Script: https://github.com/CadanHu/openclaw/blob/feat/session-restore/scripts/restore-sessions.mjs

Alternatives considered

Manual renaming, which is error-prone and time-consuming for users with large
chat histories.

Impact

  • Affected: Users upgrading from versions before Feb 2026 who had existing session history.
  • Severity: Medium (perceived data loss; data is actually archived, not deleted).
  • Frequency: One-time, on first daily reset after upgrade.
  • Consequence: Users lose sidebar access to previous chat contexts.

Additional information

Note: future daily resets will continue to archive sessions. Users should be
aware that .reset.* files are subject to automatic pruning via
session.maintenance.resetArchiveRetention (defaults to pruneAfter).
If restoration is needed, it should be done before the retention window expires.


Related issues and root cause analysis

After further investigation, this issue is part of a broader systemic gap rather than an isolated upgrade problem.

The real problem has three layers:

1. Archiving was introduced without access tooling
Sessions are archived to .reset.<timestamp> files by design (PR #14949, PR #35493), but no UI, agent tool, or API was built to surface these archives. From the user's perspective the history is gone, even though the data still exists on disk.

2. The archiving trigger is too aggressive
The current logic (updatedAt < lastDailyResetAt) archives any session last updated before today's 4 AM reset — which on first upgrade includes all existing sessions regardless of age. Only sessions that were active within the current reset window should be archived on daily reset.

3. Archives are time-limited with no recovery path
Archived files are subject to automatic pruning via session.maintenance.resetArchiveRetention. Users who don't know to act quickly will permanently lose their history with no built-in recovery option.

Related open issues:

All of the above are open as of April 2026, suggesting this is a known but unresolved area. The utility script in this issue addresses the symptom; the root fix requires either (a) correcting the reset freshness evaluation logic, or (b) exposing archived sessions through existing tools and UI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.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.enhancementNew feature or requestimpact: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.

    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