Skip to content

[Bug]: EmbeddedAttemptSessionTakeoverError during Discord runs: session file changed while embedded prompt lock was released #86508

@OC-BBBB

Description

@OC-BBBB

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Discord channel run fails after preview/status text disappears,
Exact error: EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released,
Already tried doctor --fix, gateway restart, confirmed only one gateway process, and reset ~/.openclaw/agents/main/sessions

Steps to reproduce

  1. Run OpenClaw 2026.5.22 (a374c3a) on macOS 26.5 arm64 with Node 26.0.0.
  2. Use Discord channel integration with one LaunchAgent gateway process running.
  3. Send a simple message to the Discord bot. It may reply successfully.
  4. Send a more complex request that causes the embedded agent to use tools / run longer.
  5. Discord shows the eye/status preview text, then the preview disappears and no final reply is sent.
  6. Gateway logs show EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released.

Troubleshooting already tried:

  • openclaw doctor --fix
  • openclaw gateway restart
  • Confirmed only one gateway process with pgrep / ps
  • Moved ~/.openclaw/agents/main/sessions aside and started with a fresh sessions directory
  • Re-tested and got the same error

Expected behavior

Discord requests should complete with a final reply, even for longer/tool-using runs. The session transcript should not be modified in a way that causes the embedded agent to abort its own run.

Actual behavior

For longer Discord requests, OpenClaw starts the run and shows Discord preview/status text, but then the preview disappears and no final reply is delivered. The gateway logs repeatedly show:

EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: /Users/oc-bbbb1/.openclaw/agents/main/sessions/<session-id>.jsonl

OpenClaw version

2026.5.22 (a374c3a)

Operating system

macOS 26.5 arm64, Node 26.0.0,

Install method

Homebrew/global npm-style install on macOS. CLI path from status: /opt/homebrew/bin/openclaw. Gateway command: /opt/homebrew/opt/node/bin/node /opt/homebrew/lib/node_modules/openclaw/dist/index.js gateway --port 18789. Gateway runs as macOS LaunchAgent.

Model

From gateway logs: anthropic/claude-opus-4-7, thinking=medium, fast=off.

Provider / routing chain

Discord channel integration -> main agent -> embedded agent run. Affected session key in logs: agent:main:discord:channel:1506687198391697559.

Additional provider/model setup details

Discord status/probe reports healthy: token configured, gateway reachable, connected, works, audit ok. Message Content Intent is reported as limited, but available for bots under 100 servers. No known provider auth error appears in the pasted logs.

Logs, screenshots, and evidence

13:28:05+00:00 warn plugins {"subsystem":"plugins"} [plugins] plugins.allow is empty; discovered non-bundled plugins may auto-load: discord (/Users/oc-bbbb1/.openclaw/npm/node_modules/@openclaw/discord/dist/index.js). Set plugins.allow to explicit trusted ids.
13:30:20+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=134984 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: /Users/oc-bbbb1/.openclaw/agents/main/sessions/7549b99f-9075-4826-af0d-3e1fae4a99b9.jsonl"
13:30:20+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:discord:channel:1506687198391697559 durationMs=134987 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: /Users/oc-bbbb1/.openclaw/agents/main/sessions/7549b99f-9075-4826-af0d-3e1fae4a99b9.jsonl"
13:30:20+00:00 error Embedded agent failed before reply: session file changed while embedded prompt lock was released: /Users/oc-bbbb1/.openclaw/agents/main/sessions/7549b99f-9075-4826-af0d-3e1fae4a99b9.jsonl
13:35:03+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=main durationMs=26222 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: /Users/oc-bbbb1/.openclaw/agents/main/sessions/7549b99f-9075-4826-af0d-3e1fae4a99b9.jsonl"
13:35:03+00:00 error diagnostic {"subsystem":"diagnostic"} lane task error: lane=session:agent:main:discord:channel:1506687198391697559 durationMs=26223 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: /Users/oc-bbbb1/.openclaw/agents/main/sessions/7549b99f-9075-4826-af0d-3e1fae4a99b9.jsonl"
13:35:03+00:00 error Embedded agent failed before reply: session file changed while embedded prompt lock was released: /Users/oc-bbbb1/.openclaw/agents/main/sessions/7549b99f-9075-4826-af0d-3e1fae4a99b9.jsonl

Impact and severity

Discord bot becomes unreliable for longer/tool-using requests. It may reply to simple messages, but complex requests show preview/status text and then fail without a final reply.

Medium to high. Core Discord usage is partially broken: simple replies may work, but real troubleshooting/tool-using requests fail repeatedly even after doctor, restart, single-process verification, and session reset.

Additional information

I tried solving this through the openclaw discord agent, krill.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.bugSomething isn't workingclawsweeper:needs-live-reproClawSweeper 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:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.regressionBehavior that previously worked and now fails

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions