openclaw - 💡(How to fix) Fix [Bug] Gateway restart causes WeChat session key format inconsistency - context loss after restart

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…

Root Cause

Suspected Root Cause

RAW_BUFFERClick to expand / collapse

Bug Description

After openclaw gateway restart, the same WeChat user gets two different session keys in sessions.json:

  • One missing accountId (incorrect format)
  • One with accountId (correct format)

This causes session context loss after restart, as the system cannot determine which session to restore.

Environment

  • OpenClaw: 2026.5.7
  • Channel: openclaw-weixin
  • dmScope: per-account-channel-peer
  • Account ID: 190910d6c568-im-bot
  • WeChat User ID: [email protected]
  • System: WSL2 Ubuntu 26.04

Reproduction Steps

  1. WeChat user has a normal conversation with the bot → a session key is written to sessions.json
  2. Execute openclaw gateway restart (e.g., during health check)
  3. Same WeChat user continues messaging → system generates a new session key (different format)
  4. Both session keys exist in sessions.json but point to the same user

Observed Session Keys

StateSession KeyaccountId
Before restart (incorrect)agent:main:openclaw-weixin:direct:[email protected]❌ Missing
After restart (correct)agent:main:openclaw-weixin:190910d6c568-im-bot:direct:[email protected]✅ 190910d6c568-im-bot

Expected Behavior

After restart, the system should restore the original session and continue the same conversation context.

Actual Behavior

After restart, a new session is created instead of restoring the previous one, resulting in loss of conversation history.

Suspected Root Cause

The WeChat plugin generates a session key during initial load when accountId is not yet available. This incorrect key (missing accountId) gets persisted to sessions.json. After Gateway restart, the plugin re-initializes and loads the correct accountId, but the old incorrect key already exists in sessions.json, resulting in two keys for the same user.

Severity

  • Impact: Loss of conversation context after restart
  • Frequency: Every Gateway 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 [Bug] Gateway restart causes WeChat session key format inconsistency - context loss after restart