openclaw - 💡(How to fix) Fix [Bug]: EmbeddedAttemptSessionTakeoverError on single Telegram direct turn with cron/heartbeat disabled; orphaned user repair races lane=main and telegram:direct

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

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…

On OpenClaw 2026.5.20 (macOS, M4 Mac mini), every agent turn fails before producing a reply with EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released — two lane tasks (lane=main and lane=session:agent:main:telegram:direct:<CHAT_ID>) error on the same session .jsonl ~5ms apart, reproducible on a single direct Telegram turn with cron and heartbeats disabled.

Error Message

((( 09:52:55 [gateway] http server listening (3 plugins: browser, memory-wiki, telegram; 3.1s) 09:52:55 [heartbeat] disabled 09:54:40 [telegram] Inbound message telegram:<CHAT_ID> -> @<bot> (direct, 10 chars) 09:54:46 [context-engine] Context engine "lossless-claw" is not registered; falling back to default engine "legacy". 09:54:47 [agent/embedded] Merged and removed orphaned user message to prevent consecutive user turns. runId=abae574f… sessionId=45de56a8… trigger=user 09:54:49 [diagnostic] lane task error: lane=main durationMs=3643 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: …/agents/main/sessions/45de56a8….jsonl" 09:54:49 [diagnostic] lane task error: lane=session:agent:main:telegram:direct:<CHAT_ID> durationMs=3648 error="EmbeddedAttemptSessionTakeoverError: …/agents/main/sessions/45de56a8….jsonl" 09:54:49 Embedded agent failed before reply: session file changed while embedded prompt lock was released: …/agents/main/sessions/45de56a8….jsonl )))

(On 2026.5.19 the same pattern occurred at ~167 hits in one morning, including cron and heartbeat lane pairs; 2026.5.20 reduced it to ~3, but every direct turn still fails.)

Root Cause

On OpenClaw 2026.5.20 (macOS, M4 Mac mini), every agent turn fails before producing a reply with EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released — two lane tasks (lane=main and lane=session:agent:main:telegram:direct:<CHAT_ID>) error on the same session .jsonl ~5ms apart, reproducible on a single direct Telegram turn with cron and heartbeats disabled.

Fix Action

Fix / Workaround

  • Affected: both agents (main and pepper), every direct turn, on Telegram and terminal chat mode.

  • Severity: blocks all workflow — the agent cannot return a single reply.

  • Frequency: always (deterministic; reproduces on a fresh session).

  • Consequence: agent completely unusable on 2026.5.20; no configuration workaround (cron + heartbeats disabled does not clear it); downgrade to a pre-regression release blocked by schema migration.

  • Regression window (observed): last known good = 2026.5.7 (this deployment ran it without the error); first known bad = 2026.5.19; still present on 2026.5.20 (e510042).

  • 2026.5.20 reduced occurrence count (~167/morning → ~3), consistent with cron-lane isolation #82767 landing, but every direct turn still fails via the lane=main vs session-lane race.

  • Also reproduces in terminal chat mode (no Telegram): lanes become lane=main vs lane=session:agent:main:main on the same .jsonl — not channel-specific.

  • Eliminated: memory/context plugins disabled; RAM pressure freed (gateway reachable 0ms); launch method (daemon / LaunchAgent / foreground); single token config; all sessions cleared (fresh sessions reproduce); cron + heartbeats disabled; provider rate-limit (the reason=rate_limit tag mislabels the filesystem race).

  • Candidate fixes on origin/main, newer than 2026.5.20, untested against this exact repro: #85208 fix(telegram): dedupe replayed message dispatches, fix: route direct thread event wakes to main DMs, fix: preserve route-bound direct thread events.

Code Example

(((
09:52:55 [gateway] http server listening (3 plugins: browser, memory-wiki, telegram; 3.1s)
09:52:55 [heartbeat] disabled
09:54:40 [telegram] Inbound message telegram:<CHAT_ID> -> @<bot> (direct, 10 chars)
09:54:46 [context-engine] Context engine "lossless-claw" is not registered; falling back to default engine "legacy".
09:54:47 [agent/embedded] Merged and removed orphaned user message to prevent consecutive user turns. runId=abae574f… sessionId=45de56a8… trigger=user
09:54:49 [diagnostic] lane task error: lane=main durationMs=3643 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: …/agents/main/sessions/45de56a8….jsonl"
09:54:49 [diagnostic] lane task error: lane=session:agent:main:telegram:direct:<CHAT_ID> durationMs=3648 error="EmbeddedAttemptSessionTakeoverError: …/agents/main/sessions/45de56a8….jsonl"
09:54:49 Embedded agent failed before reply: session file changed while embedded prompt lock was released:/agents/main/sessions/45de56a8….jsonl
)))

(On 2026.5.19 the same pattern occurred at ~167 hits in one morning, including cron and heartbeat lane pairs; 2026.5.20 reduced it to ~3, but every direct turn still fails.)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

On OpenClaw 2026.5.20 (macOS, M4 Mac mini), every agent turn fails before producing a reply with EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released — two lane tasks (lane=main and lane=session:agent:main:telegram:direct:<CHAT_ID>) error on the same session .jsonl ~5ms apart, reproducible on a single direct Telegram turn with cron and heartbeats disabled.

Steps to reproduce

  1. OpenClaw 2026.5.20, single agent (main), Telegram direct channel.
  2. Disable background writers: cron.enabled: false and agents.defaults.heartbeat.every: "0m" (startup log confirms [heartbeat] disabled).
  3. Optional plugins disabled; active plugins: browser, memory-wiki, telegram.
  4. Start a single foreground gateway: openclaw gateway run.
  5. In Telegram, send /new, then one direct message.
  6. The turn fails before reply with EmbeddedAttemptSessionTakeoverError; the user receives "Something went wrong while processing your request."

Expected behavior

The agent processes the single direct message and returns a reply. This deployment ran prior versions (2026.5.7) without this error; the same single-turn flow returned normal replies before the 2026.5.19 upgrade.

Actual behavior

The agent starts processing, then fails before producing a reply. User-visible: "⚠️ Something went wrong while processing your request. Please try again, or use /new to start a fresh session." The gateway logs two lane-task errors on the same session file within ~5ms, each EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released, immediately preceded by [agent/embedded] Merged and removed orphaned user message to prevent consecutive user turns.

OpenClaw version

2026.5.20 (e510042). Also observed on 2026.5.19 (a185ca2).

Operating system

macOS 26.5 (arm64), Apple M4 Mac mini.

Install method

Installed/updated via pnpm; reproduced both as a user LaunchAgent (ai.openclaw.gateway) and via foreground openclaw gateway run.

Model

anthropic/claude-sonnet-4-6

Provider / routing chain

Anthropic direct; auth = api-key (profile anthropic:default). Fallback chain: anthropic/claude-sonnet-4-6 → claude-haiku-4-5 → claude-opus-4-7.

Additional provider/model setup details

The fallback chain surfaces this as reason=rate_limit, but the detail field is the session-file race (EmbeddedAttemptSessionTakeoverError) — not an Anthropic/provider rate limit. No API keys/tokens included.

Logs, screenshots, and evidence

(((
09:52:55 [gateway] http server listening (3 plugins: browser, memory-wiki, telegram; 3.1s)
09:52:55 [heartbeat] disabled
09:54:40 [telegram] Inbound message telegram:<CHAT_ID> -> @<bot> (direct, 10 chars)
09:54:46 [context-engine] Context engine "lossless-claw" is not registered; falling back to default engine "legacy".
09:54:47 [agent/embedded] Merged and removed orphaned user message to prevent consecutive user turns. runId=abae574f… sessionId=45de56a8… trigger=user
09:54:49 [diagnostic] lane task error: lane=main durationMs=3643 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released:/agents/main/sessions/45de56a8….jsonl"
09:54:49 [diagnostic] lane task error: lane=session:agent:main:telegram:direct:<CHAT_ID> durationMs=3648 error="EmbeddedAttemptSessionTakeoverError:/agents/main/sessions/45de56a8….jsonl"
09:54:49 Embedded agent failed before reply: session file changed while embedded prompt lock was released:/agents/main/sessions/45de56a8….jsonl
)))

(On 2026.5.19 the same pattern occurred at ~167 hits in one morning, including cron and heartbeat lane pairs; 2026.5.20 reduced it to ~3, but every direct turn still fails.)

Impact and severity

  • Affected: both agents (main and pepper), every direct turn, on Telegram and terminal chat mode.
  • Severity: blocks all workflow — the agent cannot return a single reply.
  • Frequency: always (deterministic; reproduces on a fresh session).
  • Consequence: agent completely unusable on 2026.5.20; no configuration workaround (cron + heartbeats disabled does not clear it); downgrade to a pre-regression release blocked by schema migration.

Additional information

  • Regression window (observed): last known good = 2026.5.7 (this deployment ran it without the error); first known bad = 2026.5.19; still present on 2026.5.20 (e510042).
  • 2026.5.20 reduced occurrence count (~167/morning → ~3), consistent with cron-lane isolation #82767 landing, but every direct turn still fails via the lane=main vs session-lane race.
  • Also reproduces in terminal chat mode (no Telegram): lanes become lane=main vs lane=session:agent:main:main on the same .jsonl — not channel-specific.
  • Eliminated: memory/context plugins disabled; RAM pressure freed (gateway reachable 0ms); launch method (daemon / LaunchAgent / foreground); single token config; all sessions cleared (fresh sessions reproduce); cron + heartbeats disabled; provider rate-limit (the reason=rate_limit tag mislabels the filesystem race).
  • Candidate fixes on origin/main, newer than 2026.5.20, untested against this exact repro: #85208 fix(telegram): dedupe replayed message dispatches, fix: route direct thread event wakes to main DMs, fix: preserve route-bound direct thread events.

GITHUB_ISSUE_84250_session_takeover_runner_self_race.md

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…

FAQ

Expected behavior

The agent processes the single direct message and returns a reply. This deployment ran prior versions (2026.5.7) without this error; the same single-turn flow returned normal replies before the 2026.5.19 upgrade.

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 - 💡(How to fix) Fix [Bug]: EmbeddedAttemptSessionTakeoverError on single Telegram direct turn with cron/heartbeat disabled; orphaned user repair races lane=main and telegram:direct