openclaw - 💡(How to fix) Fix Feature: session.maintenance.preserveKeys config to exempt specific sessions from pruning

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…

Fix Action

Fix / Workaround

Current Workaround

Code Example

{
  "session": {
    "maintenance": {
      "mode": "enforce",
      "pruneAfter": "3d",
      "preserveKeys": ["agent:ceo:main"]
    }
  }
}
RAW_BUFFERClick to expand / collapse

Problem

The session maintenance system currently prunes stale sessions after pruneAfter (default 30d, commonly set lower). Some sessions should never be pruned — notably the primary WebUI session (agent:ceo:main) which users expect to always find in their session list.

Currently, isProtectedSessionMaintenanceEntry() auto-protects group/channel/thread sessions, and preserveKeys exists as a runtime parameter — but there is no config field to specify session keys that should always be preserved.

This means a user who sets pruneAfter: 3d and goes 4 days without using the WebUI will find their main session gone, with only Discord channel sessions visible. They have to create a new session to get back to normal.

Proposed Solution

Add a session.maintenance.preserveKeys config field (array of session key patterns or exact keys):

{
  "session": {
    "maintenance": {
      "mode": "enforce",
      "pruneAfter": "3d",
      "preserveKeys": ["agent:ceo:main"]
    }
  }
}

The runtime preserveKeys parameter (already used by pruneStaleEntries and capEntryCount) would merge these config values with the dynamically computed set (e.g., activeSessionKey).

Current Workaround

A daily cron job that bumps updatedAt on the main session entry in sessions.json. Functional but fragile — direct JSON manipulation of gateway state is not ideal.

Environment

  • OpenClaw 2026.5.7
  • Config: session.maintenance.mode: enforce, pruneAfter: 3d

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