Repository navigation
Description
Summary
On Discord (and likely any channel using reply session initialization), the first inbound message succeeds but the second message always fails with:
reply session initialization conflicted for agent:main:discord:channel:<channelId>
Root cause is a false positive stale-snapshot in optimistic concurrency: createReplySessionInitializationRevision() serializes the full session entry via JSON.stringify, but snapshot load and commit compare different shapes of skillsSnapshot.
Environment
- OpenClaw 2026.6.10 (commit
a96418c) - Channel: Discord
- Single agent (
main), minimal config - Repro: send two messages in the same Discord channel; first OK, second fails
Root cause
loadReplySessionInitializationSnapshot() loads the store with default hydration, which persists skillsSnapshot as { skills: [...], promptRef: "..." }.
Inside commitReplySessionInitialization(), the writer's in-memory store is loaded with hydrated skill prompt blobs, so the same field becomes { skills: [...], prompt: "<full text>" }.
Revision comparison then fails even when updatedAt / lastInteractionAt are identical. Diagnostic logs showed:
fieldDiff.changedKeys: ['skillsSnapshot']firstDiffIndexaround 1036- JSON diff at that index:
"skills"(expected) vs"prompt"(actual)
After the first agent run writes a full skillsSnapshot, the second inbound turn's init snapshot no longer matches the commit-time revision built from the hydrated writer cache → retry once → hard conflict.
Suggested fix
Use the same persisted shape for revision on both paths:
loadReplySessionInitializationSnapshot:loadSessionStore(..., { hydrateSkillPromptRefs: false })commitReplySessionInitialization: when building the revision for comparison, re-read from disk withhydrateSkillPromptRefs: falseinstead of using the writer cache entry (which may be hydrated).
Alternative: change revision to exclude or normalize skillsSnapshot.prompt vs promptRef.
Secondary issue (optional hardening)
In src/channels/session.ts, recordInboundSession used void metaTask before updateLastRoute, allowing concurrent writes to the same session store. Changing to await metaTask avoids an additional race (not the primary cause of the every-second-message failure).
Verified locally
With the two changes above, consecutive Discord messages succeed (no stale-snapshot, model fetch 200 on second turn).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 25, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 25, 2026, 3:54 AM ET / 07:54 UTC.
Summary
Keep open: current main still has a source-level path where reply-session initialization revisions compare whole JSON-stringified session entries while skill prompt blob hydration can change the in-memory
skillsSnapshotshape/order. The open Telegram PR overlaps the generic stale-snapshot symptom but does not address this reported hydration mismatch, so this issue remains actionable.Reproducibility: yes. at source level: the current revision guard JSON-stringifies the full entry, while skill snapshot creation and blob hydration can preserve the same data with different
skillsSnapshotshape/order. I did not run the live Discord two-message flow in this read-only review.Next step
This is a narrow core session-state repair with clear source evidence, likely files, and a focused test path; no product decision or new config surface is needed.
Review details
Best possible solution:
Normalize reply-session initialization revisions at the session accessor/storage boundary so persisted and hydrated
skillsSnapshotentries compare by the same durable shape, with a focused regression test for prompt blob hydration.Do we have a high-confidence way to reproduce the issue?
Yes at source level: the current revision guard JSON-stringifies the full entry, while skill snapshot creation and blob hydration can preserve the same data with different
skillsSnapshotshape/order. I did not run the live Discord two-message flow in this read-only review.Is this the best way to solve the issue?
Yes, the reporter's suggested persisted-shape or normalized revision comparison is the narrowest maintainable fix. The optional
recordInboundSessionordering hardening should be added only with a separate focused test if it proves necessary.AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 31e941c3fc32.
Label changes
Label changes:
P1: The report describes a currently broken Discord channel workflow where the second inbound message fails before a reply can be generated.impact:message-loss: The failed reply-session initialization prevents the user's second Discord message from reaching a successful agent reply path.impact:session-state: The root problem is stale-snapshot detection over session metadata, specifically the persisted versus hydratedskillsSnapshotstate.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:linked-pr-open: Current issue advisory state selects this label.clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.clawsweeper:queueable-fix: Current issue advisory state selects this label.clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P1: The report describes a currently broken Discord channel workflow where the second inbound message fails before a reply can be generated.impact:message-loss: The failed reply-session initialization prevents the user's second Discord message from reaching a successful agent reply path.impact:session-state: The root problem is stale-snapshot detection over session metadata, specifically the persisted versus hydratedskillsSnapshotstate.Evidence reviewed
Acceptance criteria:
What I checked:
createReplySessionInitializationRevision()returnsJSON.stringify(entry ?? null), so equivalent session entries with different hydrated/persistedskillsSnapshotkey order or shape can compare unequal. (src/config/sessions/session-accessor.ts:1158, 31e941c3fc32)loadReplySessionInitializationSnapshot()reads the store with default skill-prompt hydration, andcommitReplySessionInitialization()builds a second revision from the writer store before returningreason: "stale-snapshot"on mismatch. (src/config/sessions/session-accessor.ts:1695, 31e941c3fc32)promptbeforeskills, while prompt blob hydration stripspromptReffrom the persisted snapshot and appendspromptafter the rest of the object. (src/skills/loading/workspace.ts:1411, 31e941c3fc32)dispatchChannelInboundReplywithrecordInboundSession, and the channel turn kernel records the inbound session before dispatching the reply run, so shared reply-session initialization failures can block a visible Discord reply. (extensions/discord/src/monitor/message-handler.process.ts:932, 31e941c3fc32)skillsSnapshotrevision comparison insession-accessor.ts. (8e24cb1c873f)jalehmanmerged the guarded reply-session initialization in 95e37f8, whilesteipeteintroduced persisted skill prompt blobs in edd4c62. (src/config/sessions/session-accessor.ts:1691, 95e37f8e9517)Likely related people:
src/config/sessions/session-accessor.ts,src/auto-reply/reply/session.ts)src/config/sessions/skill-prompt-blobs.ts,src/config/sessions/store-load.ts,src/config/sessions/store.ts)skillsSnapshotstorage area. (role: adjacent prompt-blob repair contributor; confidence: medium; commits: 4d13055ca564; files:src/config/sessions/skill-prompt-blobs.ts,src/config/sessions/store.ts)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.elliott-dandelion-cult commentedon Jun 27, 2026
Field observation from the
191a7af989deployed proof cycle (2026-06-27): this class is still operationally relevant on Discord, and/newmust be treated as a workaround, not an acceptable steady-state cure.Observed shape in cohort runtime:
/newbecause the Discord reply path had previously shownreply session initialization conflictedbehavior on the shared channel session./newwould only rotate/replace the affected session state.Boundary for tracking:
/newas the cure for this bug family. It destroys/rotates conversational continuity and can hide the reply-session conflict root cause.reply session initialization conflictedlog window, session-state shape, and whether persisted-vs-hydrated entry comparison is involved.openclaw/openclaw#96936remains the likely fix/verification lane, but it needs direct behavior proof that the affected Discord/Telegram reply-init flow no longer requires session reset.This is a field note to keep the bug tracked instead of sweeping the unhealthy state to
/new.joshavant commentedon Jun 29, 2026
Thanks @wiidz for the clear original report and root-cause notes.
This was fixed by #97657, merged in 75db48a. The landed fix keeps reply-session runtime snapshots hydrated, but computes the optimistic revision from the canonical persisted session-entry shape. That makes persisted
skillsSnapshot.promptRef, hydratedskillsSnapshot.prompt, and runtime-onlyresolvedSkillscompare as the same durable session state, while still rejecting real stale writes.The fix was verified with focused session-store coverage plus live Discord before/after proof: the reverted-fix run reproduced the second-message stale-snapshot conflict, and the fixed run successfully handled consecutive Discord replies after
skillsSnapshot.promptRefwas present.Closing as fixed by #97657.