openclaw - ✅(Solved) Fix [Bug] sessions.json sessionId and sessionFile point to different transcript files causing history mismatch [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

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…
GitHub stats
openclaw/openclaw#60886Fetched 2026-04-08 02:46:06
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Error Message

Gateway log shows frequent websocket reconnections (20:14-20:19) followed by SIGTERM restart and delivery-recovery:

[delivery-recovery] Found 1 pending delivery entries — starting recovery

No explicit session routing error was logged, suggesting the split happened silently.

-- Reported via OpenClaw agent on behalf of the user.

Root Cause

Root Cause Hypothesis

Fix Action

Fixed

PR fix notes

PR #60896: Fix: sync sessionFile in touchSessionStore

Description (problem / solution / changelog)

Summary

Good day,

This PR fixes issue #60886 where sessionId and sessionFile in sessions.json point to different transcript files after WebSocket reconnections.

Root Cause

The touchSessionStore function only updates sessionId but never updates sessionFile. When node events trigger transcript writes, the new file path is not synched to the sessions store.

Fix

  • Add sessionFile parameter to touchSessionStore function
  • Preserve existing sessionFile when not explicitly provided

Testing

Build passes. Manual verification through normal session flow recommended.

Thank you for your attention. If there are any issues or suggestions, please leave a comment and I will address them promptly.

Warmly, Jah-yee https://github.com/Jah-yee

Changed files

  • src/gateway/server-node-events.ts (modified, +2/-0)

Code Example

{
  "sessionId": "f4b82d75-4541-4513-87a2-53ca5322e520",  // points to OLD transcript (stopped at 16:05)
  "sessionFile": "/path/to/77f85a38-6b3e-4900-8efa-0fc5f50eab97.jsonl"  // actual active transcript
}

---

[delivery-recovery] Found 1 pending delivery entries — starting recovery
RAW_BUFFERClick to expand / collapse

Bug Description

When the gateway experiences websocket instability or restarts, the sessions.json file can end up with sessionId and sessionFile pointing to different transcript files. This causes the UI (both WebChat and TUI) to read an older transcript file while the gateway continues writing to a different one, resulting in the user seeing stale conversation history.

Steps to Reproduce

  1. Use WebChat for normal conversation
  2. Gateway experiences websocket reconnections (e.g. due to network instability)
  3. After reconnections, gateway continues writing to the active transcript file
  4. But sessions.json entry for the session maps to an older transcript via sessionId
  5. UI reads from sessionId → shows stale messages; new messages not visible

Environment

  • OpenClaw version: 2026.4.2 (d74a122)
  • OS: macOS
  • Channel: webchat / openclaw-tui

Observed Behavior

sessions.json for agent:main:main:

{
  "sessionId": "f4b82d75-4541-4513-87a2-53ca5322e520",  // points to OLD transcript (stopped at 16:05)
  "sessionFile": "/path/to/77f85a38-6b3e-4900-8efa-0fc5f50eab97.jsonl"  // actual active transcript
}
  • Old transcript last message: 2026-04-04T08:05:21.599Z (16:05 GMT+8)
  • Active transcript last message: 2026-04-04T13:39:50.261Z (21:39 GMT+8, current)
  • The gateway was writing to the active transcript but sessionId was never updated

Root Cause Hypothesis

The sessionId field in sessions.json is not being updated when the gateway switches to a new or different transcript file during websocket reconnection or restart. The gateway uses sessionFile (which is kept current) but the UI reads sessionId to locate the transcript, creating an inconsistency.

Impact

  • Users see stale conversation history after any gateway reconnect/restart event
  • Severity: HIGH — users lose visibility into recent conversation context
  • Related to: #51549 (WebChat loses message queue and history on refresh), but distinct in that history IS being persisted, just to the wrong file

Suggested Fix

  1. Ensure sessionId is always updated when a new transcript file is selected/written
  2. Alternatively, make UI read from sessionFile instead of sessionId when looking up transcript
  3. Add a consistency check on gateway startup to detect and repair mismatched sessionId/sessionFile pairs

Logs

Gateway log shows frequent websocket reconnections (20:14-20:19) followed by SIGTERM restart and delivery-recovery:

[delivery-recovery] Found 1 pending delivery entries — starting recovery

No explicit session routing error was logged, suggesting the split happened silently.

-- Reported via OpenClaw agent on behalf of the user.

extent analysis

TL;DR

Update the sessionId field in sessions.json to match the current sessionFile when the gateway switches to a new transcript file during websocket reconnection or restart.

Guidance

  • Verify that the sessionId field is being updated correctly by checking the sessions.json file after a websocket reconnection or restart.
  • Consider implementing a consistency check on gateway startup to detect and repair mismatched sessionId/sessionFile pairs.
  • Alternatively, update the UI to read from sessionFile instead of sessionId when looking up the transcript, to ensure it always reads from the current transcript file.
  • Review the gateway log to identify patterns or triggers for websocket reconnections and restarts, to help prevent or mitigate the issue.

Example

No explicit code example is provided, as the issue does not specify the programming language or implementation details. However, the suggested fix implies that the sessionId field should be updated to match the current sessionFile when the gateway switches to a new transcript file.

Notes

The issue seems to be specific to the OpenClaw version 2026.

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 - ✅(Solved) Fix [Bug] sessions.json sessionId and sessionFile point to different transcript files causing history mismatch [1 pull requests, 1 participants]