openclaw - 💡(How to fix) Fix openclaw sessions cleanup crashes: validateSessionId rejects agent:<id>:main session key (regex excludes ':') [3 pull requests]

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…

Error Message

$ openclaw sessions cleanup --dry-run --fix-missing Error: Invalid session ID: agent:main:main

Root Cause

Root cause: In dist/paths-*.js:

const SAFE_SESSION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/i;
function validateSessionId(sessionId) {
  const trimmed = sessionId.trim();
  if (!SAFE_SESSION_ID_RE.test(trimmed) || isCompactionCheckpointTranscriptFileName(`${trimmed}.jsonl`))
    throw new Error(`Invalid session ID: ${sessionId}`);
  return trimmed;
}

The cleanup path passes a session key (agent:main:main, which legitimately contains :) where a session id (UUID) is expected, so SAFE_SESSION_ID_RE rejects it. Looks like a regression of #15661 / #16211 for the sessions cleanup command specifically.

Fix Action

Fixed

Code Example

$ openclaw sessions cleanup --dry-run --fix-missing
Error: Invalid session ID: agent:main:main

---

const SAFE_SESSION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/i;
function validateSessionId(sessionId) {
  const trimmed = sessionId.trim();
  if (!SAFE_SESSION_ID_RE.test(trimmed) || isCompactionCheckpointTranscriptFileName(`${trimmed}.jsonl`))
    throw new Error(`Invalid session ID: ${sessionId}`);
  return trimmed;
}
RAW_BUFFERClick to expand / collapse

Version: OpenClaw 2026.5.7 (eeef486), Linux (Raspberry Pi), claude-cli runtime

What happens: Every form of openclaw sessions cleanup fails immediately:

$ openclaw sessions cleanup --dry-run --fix-missing
Error: Invalid session ID: agent:main:main

Same for --enforce, --agent main, --all-agents, etc. The command is effectively unusable, so stale sessions (e.g. completed agent:<id>:subagent:* entries) are never pruned — related to #47975.

Root cause: In dist/paths-*.js:

const SAFE_SESSION_ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/i;
function validateSessionId(sessionId) {
  const trimmed = sessionId.trim();
  if (!SAFE_SESSION_ID_RE.test(trimmed) || isCompactionCheckpointTranscriptFileName(`${trimmed}.jsonl`))
    throw new Error(`Invalid session ID: ${sessionId}`);
  return trimmed;
}

The cleanup path passes a session key (agent:main:main, which legitimately contains :) where a session id (UUID) is expected, so SAFE_SESSION_ID_RE rejects it. Looks like a regression of #15661 / #16211 for the sessions cleanup command specifically.

Repro: Any store with the default persistent agent:<id>:main key (i.e. essentially all installs) → openclaw sessions cleanup.

Expected: cleanup resolves the session id from the key (or skips/validates keys vs ids correctly) instead of throwing.

Possibly also relevant: #56079 (mismatched sessionId/sessionFile after restart) — observed here too on a WhatsApp DM key after an auto-update restart.

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 openclaw sessions cleanup crashes: validateSessionId rejects agent:<id>:main session key (regex excludes ':') [3 pull requests]