Repository navigation
Description
Bug type
Regression (worked before, now fails)
Beta release blocker
No
Summary
In OpenClaw v2026.5.2, the webchat session JSONL transcript is overwritten on every turn — only the latest message exchange survives. On page refresh, all previous messages are gone. This worked correctly on v2026.4.29.
Root cause
mirrorCodexAppServerTranscript (in run-attempt-*.js) receives the full conversation history via messagesSnapshot (built from readMirroredSessionHistoryMessages at line 3264) and rewrites ALL messages to the JSONL every turn. Each message is written via appendCodexAppServerTranscriptMessage, which calls migrateLinearTranscriptToParentLinked — a function that reads the entire file and rewrites it via fs.writeFile (not append).
The per-turn idempotencyScope (codex-app-server:${threadId}:${turnId}) changes every turn, so old messages get new keys and bypass the idempotency check. The rewrite creates new entries with different parentId chains, causing selectBoundedActiveTailRecords (the tree walk) to follow the newest branch and orphan previous entries.
In v4.29, SessionManager.open().appendMessage() truly appended to the file. The SessionManager was removed in 5.2 and replaced with this read-migrate-rewrite cycle.
Steps to reproduce
- Open webchat on v2026.5.2
- Send message 1, receive response
- Send message 2, receive response
- Check the session JSONL — message 1's assistant response is gone
- Refresh page — only message 2 and its response are visible
Evidence
Controlled test on macOS arm64, v2026.5.2 (8b2a6e5), stock dist (no patches except prewarm skip):
- Took a JSONL snapshot between turns
- Diffed after the next turn
- The previous assistant response (id
44b4ec62, parentIdd3471f25) was replaced by the new user message (id9f4b19a1, parentIdd3471f25) — same parent, sibling branch - The tree walk follows the new branch, orphaning the old assistant entry
- 9 minutes between turns — no race condition, purely the mirror rewrite logic
Contributing factors
migrateLinearTranscriptToParentLinkedrewrites viawriteFile— any concurrent access or stale read loses data- Per-turn
turnIdin idempotency scope — old messages get new keys, bypassing dedup - Write lock race (fix: session write lock race — async release can delete newly-acquired lock #57019) —
releaseHeldLockdeletesHELD_LOCKSbefore async cleanup, allowing concurrent acquirers on macOS appendCodexAppServerTranscriptMessagecalls migration inside the lock butmirrorCodexAppServerTranscripttakes a separate lock per batch — interleaving between the webchat write path and the mirror write path can race
Code references (v2026.5.2 dist)
run-attempt-CektiLYp.js:3264—finalMessages = readMirroredSessionHistoryMessages(sessionFile)(full history)run-attempt-CektiLYp.js:3598—idempotencyScope: codex-app-server:${threadId}:${turnId}(per-turn keys)run-attempt-CektiLYp.js:2082—appendCodexAppServerTranscriptMessagetriggers migrationtranscript-C_uDP9Gl.js:121—migrateLinearTranscriptToParentLinkedrewrites file viawriteFiletranscript-C_uDP9Gl.js:156—fs.writeFile(transcriptPath, ...)— destructive overwritesession-utils.fs-W0CAUUsv.js:564—selectBoundedActiveTailRecordstree walk follows one branch
What changed (4.29 → 5.2)
| 4.29 | 5.2 | |
|---|---|---|
| Write method | SessionManager.open().appendMessage() — true append |
appendCodexAppServerTranscriptMessage → migrateLinearTranscriptToParentLinked → writeFile — full rewrite |
| Session read | readSessionMessages — sync, reads all |
readRecentSessionMessagesAsync — async, tail window + tree walk |
| Branch resolution | SessionManager.open().getBranch() |
selectBoundedActiveTailRecords — drops orphaned branches |
| Mirror scope | Current turn only | Full messagesSnapshot (entire history) |
| Idempotency | N/A (true append) | Per-turn scope — changes every turn, old messages get new keys |
Environment
- OpenClaw: v2026.5.2 (8b2a6e5), npm global install
- OS: macOS 26.4.0 arm64 (Mac Mini M4 Pro)
- Node: 22
- Channels affected: WebChat (Telegram and BlueBubbles unaffected — different write path)
Related issues
- fix: session write lock race — async release can delete newly-acquired lock #57019 — Write lock race (contributing factor, not root cause)
- WebChat: assistant text responses not persisted to session transcript (5.2 regression) #76804 — Assistant text not persisted (separate issue, PR feat(gateway/transcript): add silent option to assistant transcript append helper #76819 merged)
- [Bug]: Control UI Chat History Display Issues #76892, [Bug]:the messages often disspear #76763, [Bug]: Control UI: chat history intermittently shows only the latest message in 2006.5.2 #76384 — Duplicate reports of history loss
- [Bug]: WebChat loses message queue, conversation history, and draft on browser refresh #51549 — Architectural gap in webchat persistence
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon May 4, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 28, 2026, 10:21 AM ET / 14:21 UTC.
Summary
Keep this issue open: current main contains the merged Codex app-server mirror idempotency repair from #77046, but that PR explicitly scoped itself as a partial fix and the remaining long-session, cross-channel, and compaction-related transcript-loss path has not been proven resolved on current main.
Reproducibility: yes. for the already-fixed mirror-idempotency subpath from source and tests, but no high-confidence current-main live reproduction yet for the broader long-session and cross-channel transcript-loss path.
Next step
Maintainer review and live repro are needed before another fix PR because the known Codex mirror subpath is already fixed and the remaining writer path is not isolated.
Review details
Best possible solution:
Keep this issue as the canonical tracker until maintainers have a current-main long-session or cross-channel reproduction with before/after JSONL snapshots, then fix the specific transcript writer that creates orphaned or sibling parent-linked records.
Do we have a high-confidence way to reproduce the issue?
Yes for the already-fixed mirror-idempotency subpath from source and tests, but no high-confidence current-main live reproduction yet for the broader long-session and cross-channel transcript-loss path.
Is this the best way to solve the issue?
No final fix is proven yet; #77046 is a good partial repair, but the best remaining path is targeted live repro plus source tracing of whichever writer still breaks the parent-linked transcript chain.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 4d292caaa429.
Label changes
Label changes:
maturity:stable: The affected Gateway chat.history and hosted WebChat/session surface maps to gateway-runtime, which is scored M4 Stable.Label justifications:
P1: The reported regression can make prior WebChat/session history disappear for real users, affecting an active agent workflow rather than only polish.impact:data-loss: The issue is about durable session transcript records becoming missing or effectively unreachable from user-visible history.impact:message-loss: The reported symptom is prior user and assistant messages disappearing from WebChat and related session replay views.impact:session-state: The suspected root cause involves parent-linked transcript state, session history projection, cross-channel session continuity, and compaction.maturity:stable: The affected Gateway chat.history and hosted WebChat/session surface maps to gateway-runtime, which is scored M4 Stable.Evidence reviewed
Acceptance criteria:
What I checked:
extensions/codex/src/app-server/transcript-mirror.ts:101, 4d292caaa429)extensions/codex/src/app-server/event-projector.ts:339, 4d292caaa429)extensions/codex/src/app-server/transcript-mirror.test.ts:523, 4d292caaa429)src/gateway/session-utils.fs.ts:351, 4d292caaa429)docs/web/webchat.md. (docs/web/webchat.md:25, 4d292caaa429)Likely related people:
extensions/codex/src/app-server/transcript-mirror.ts,extensions/codex/src/app-server/event-projector.ts,extensions/codex/src/app-server/run-attempt.ts)src/plugin-sdk/session-transcript-runtime.ts,src/config/sessions/transcript-append.ts)src/gateway,src/channels)src/config/sessions,src/agents,src/gateway)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.mjamiv commentedon May 4, 2026
Opened a narrow regression-test PR for the active-branch case discussed here: #77051
What it covers:
readSessionMessagesstill sees both turns after the second mirror, matching the refresh-visible history pathValidation:
pnpm test extensions/codex/src/app-server/transcript-mirror.test.ts --runpassed locally in a fresh upstream-main worktree.I did not claim this fully reproduces the live WebChat overwrite report; this PR pins the focused branch-preservation regression that ClawSweeper suggested.
fix: make migrateLinearTranscriptToParentLinked idempotent
bijiashui commentedon May 7, 2026
我也是同样问题。
环境:
具体表现:
jsonl 证据:
影响:
这不是刷新页面丢数据的问题,而是整个会话的历史在存储层就丢失了。报销单讨论的中间结果无法追溯,需要重新做一遍。
重现步骤:
这个问题严重影响了会话的可用性,希望能尽快修复。谢谢。
barnacle-openclaw commentedon May 30, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
dertbv commentedon Jun 5, 2026
Still relevant on v2026.5.28 (
openclaw --version→2026.5.28 (e932160), npm-global, macOS Mac Mini M4 Pro arm64, LaunchAgent 24/7).Status check on this issue:
clawsweeper:linked-pr-openlabel is now stale (linked PR is closed).Spot-check on our v5.28 box (2026-06-05): today's 3-turn WebChat session (10:55→11:09 ET) preserved all user turns in the on-disk JSONL with proper
parentIdchains — no overwrite fingerprint under simple multi-turn usage. This suggests the bug requires the longer cross-channel + compaction pattern @bijiashui described, not the basic multi-turn case.Flagging so this doesn't auto-close — the P1 /
impact:session-state/impact:data-loss/impact:message-losslabels still match the reported behavior, and WebChat transcript persistence is load-bearing for any install running Control UI alongside cron-backed channels.Happy to capture a fresh on-disk JSONL diff from our v5.28 box if a maintainer wants concrete bytes — let me know what reproducer shape would be most useful (longer session? cross-channel handoff? specific compaction trigger?).
openclaw-barnacle commentedon Jul 13, 2026
This issue has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.
dertbv commentedon Jul 14, 2026
No longer reproduces on v2026.7.1-beta.5 (b6387af) — same machine as the original report (macOS arm64, Mac Mini M4 Pro, npm-global, LaunchAgent 24/7), codex app-server runtime.
Re-ran the original snapshot/diff method against a fresh gateway session (two turns via the gateway API, session JSONL snapshotted between turns):
diffclean) — the file was appended, not rewritten.user 17045e2e ← assistant 5e48b3eb ← user ed0a69ed ← assistant 3d3b8a0d. The 5.2 failure signature (new message written as a sibling of the old parent, orphaning the previous assistant entry) is absent.Caveat: this exercised the gateway session/transcript write path (codex app-server runtime) rather than the WebChat UI specifically, but that mirror path was the root cause identified above, and it now truly appends. Consistent with the transcript persistence having been reworked wholesale in the 7.x line.
From my side this can close as fixed/superseded on the current beta line. (Original repro was v2026.5.2; last confirmed still-present v2026.5.28.)
steipete commentedon Jul 29, 2026
Thank you for the exceptionally detailed reproduction and, especially, for retesting the original Codex app-server runtime on the same Mac and confirming that the existing transcript remains byte-identical across turns and that the parent chain stays linear: #77012 (comment).
I independently checked the current implementation against Codex’s actual upstream thread/turn protocol. The underlying destructive file-era transcript persistence was subsequently replaced by the canonical SQLite, parent-linked, transaction-backed session transcript implementation in #113233 (commit 4273ca9). The earlier #77046 fixes the related Codex mirror identity/idempotency subpath; it is a partial contributing fix, not the sole resolution of this report.
The complete current Codex transcript-mirror regression suite passes 28/28, including reordered snapshots, distinct repeated-message turns, and earlier-turn history re-emitted by later snapshots. In combination with the original reporter’s byte-for-byte, same-machine confirmation, this verifies the originally reported per-turn overwrite and orphaned-parent regression is fixed. Closing as completed; genuinely different cross-channel or compaction failures should remain tracked separately when supported by their own current reproduction.