-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: WebChat session transcript overwritten on every turn (5.2 regression — SessionManager removal) #77012
Copy link
Copy link
Open
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.
Description
Metadata
Metadata
Assignees
Labels
P1High-priority user-facing bug, regression, or broken workflow.High-priority user-facing bug, regression, or broken workflow.clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.ClawSweeper needs live local, crabbox, or manual validation to confirm this issue.clawsweeper:needs-maintainer-reviewClawSweeper marked this issue as needing maintainer review before automation.ClawSweeper marked this issue as needing maintainer review before automation.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.ClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.Channel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.Good issue quality with a plausible reproduction path needing some confirmation.maturity:stableIssue affects a taxonomy feature currently scored M4/M5.Issue affects a taxonomy feature currently scored M4/M5.
Type
Fields
Priority
None yet
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(inrun-attempt-*.js) receives the full conversation history viamessagesSnapshot(built fromreadMirroredSessionHistoryMessagesat line 3264) and rewrites ALL messages to the JSONL every turn. Each message is written viaappendCodexAppServerTranscriptMessage, which callsmigrateLinearTranscriptToParentLinked— a function that reads the entire file and rewrites it viafs.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 differentparentIdchains, causingselectBoundedActiveTailRecords(the tree walk) to follow the newest branch and orphan previous entries.In v4.29,
SessionManager.open().appendMessage()truly appended to the file. TheSessionManagerwas removed in 5.2 and replaced with this read-migrate-rewrite cycle.Steps to reproduce
Evidence
Controlled test on macOS arm64, v2026.5.2 (8b2a6e5), stock dist (no patches except prewarm skip):
44b4ec62, parentIdd3471f25) was replaced by the new user message (id9f4b19a1, parentIdd3471f25) — same parent, sibling branchContributing factors
migrateLinearTranscriptToParentLinkedrewrites viawriteFile— any concurrent access or stale read loses dataturnIdin idempotency scope — old messages get new keys, bypassing dedupreleaseHeldLockdeletesHELD_LOCKSbefore async cleanup, allowing concurrent acquirers on macOSappendCodexAppServerTranscriptMessagecalls migration inside the lock butmirrorCodexAppServerTranscripttakes a separate lock per batch — interleaving between the webchat write path and the mirror write path can raceCode 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 branchWhat changed (4.29 → 5.2)
SessionManager.open().appendMessage()— true appendappendCodexAppServerTranscriptMessage→migrateLinearTranscriptToParentLinked→writeFile— full rewritereadSessionMessages— sync, reads allreadRecentSessionMessagesAsync— async, tail window + tree walkSessionManager.open().getBranch()selectBoundedActiveTailRecords— drops orphaned branchesmessagesSnapshot(entire history)Environment
Related issues