openclaw - 💡(How to fix) Fix Bug: EmbeddedAttemptSessionTakeoverError kills active session when Control UI accesses it

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…

When an embedded agent session is actively running (mid-model-call), if a second client (e.g. Control UI via webchat) accesses the same session — even read-only operations like sessions.list or chat.history — the embedded session is killed by EmbeddedAttemptSessionTakeoverError. The session file changes while the embedded prompt lock is released, triggering the takeover guard, which terminates the running lane task.

Expected: Active sessions should not be killed when another client reads session state. Actual: Any client access to a session with an active embedded run causes fatal takeover error.


Error Message

// AGENT RUNNING — long model call in progress {"diagnostic","1":"long-running session: sessionId=534e56b0... sessionKey=agent:marcus:main state=processing age=146s ..."}

// WEBSOCKET DISCONNECT (first client) {"gateway/ws","1":"webchat disconnected code=1001 reason=n/a conn=95448759..."}

// SECOND CLIENT (Control UI) IMMEDIATELY RECONNECTS AND READS SESSION STATE {"gateway/ws","1":"webchat connected conn=4fdbed1e... remote=127.0.0.1 client=openclaw-control-ui webchat vcontrol-ui"} {"gateway/ws","1":"⇄ res ✓ agents.list 162ms conn=4fdbed1e..."} {"gateway/ws","1":"⇄ res ✓ chat.history 148ms conn=4fdbed1e..."} {"gateway/ws","1":"⇄ res ✓ sessions.list 256ms conn=4fdbed1e..."}

// EMBEDDED SESSION KILLED — session file changed while lock released {"diagnostic","1":"lane task error: lane=main durationMs=456451 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: .../534e56b0-2f9d-46f9-83b7-94e98b47e2a9.jsonl""} {"diagnostic","1":"lane task error: lane=session:agent:marcus:main durationMs=456455 error="EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: .../534e56b0-2f9d-46f9-83b7-94e98b47e2a9.jsonl""}

// SECOND INCIDENT — same pattern, different duration {"diagnostic","1":"lane task error: lane=main durationMs=194036 error="EmbeddedAttemptSessionTakeoverError: ..."} {"diagnostic","1":"lane task error: lane=session:agent:marcus:main durationMs=194041 error="EmbeddedAttemptSessionTakeoverError: ..."}

Root Cause

The embedded agent runner releases the session file lock during model calls. When a second client (Control UI) accesses the same session mid-call, it modifies the session file. The takeover guard detects this modification and throws EmbeddedAttemptSessionTakeoverError, which is treated as fatal and kills the lane task.

The issue is in how session file locking interacts with lane scheduling:

  • Embedded run holds a prompt lock on the session file
  • During model calls, the lock is temporarily released
  • A second client's access during this window modifies the file
  • On return, the lock acquisition detects the modification and rejects the takeover
  • This is treated as a fatal lane error rather than a recoverable race condition

Code Example

// AGENT RUNNING — long model call in progress
{"diagnostic","1":"long-running session: sessionId=534e56b0... sessionKey=agent:marcus:main state=processing age=146s ..."}


// WEBSOCKET DISCONNECT (first client)
{"gateway/ws","1":"webchat disconnected code=1001 reason=n/a conn=95448759..."}


// SECOND CLIENT (Control UI) IMMEDIATELY RECONNECTS AND READS SESSION STATE
{"gateway/ws","1":"webchat connected conn=4fdbed1e... remote=127.0.0.1 client=openclaw-control-ui webchat vcontrol-ui"}
{"gateway/ws","1":"⇄ res ✓ agents.list 162ms conn=4fdbed1e..."}
{"gateway/ws","1":"⇄ res ✓ chat.history 148ms conn=4fdbed1e..."}
{"gateway/ws","1":"⇄ res ✓ sessions.list 256ms conn=4fdbed1e..."}

// EMBEDDED SESSION KILLED — session file changed while lock released
{"diagnostic","1":"lane task error: lane=main durationMs=456451 error=\"EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: .../534e56b0-2f9d-46f9-83b7-94e98b47e2a9.jsonl\""}
{"diagnostic","1":"lane task error: lane=session:agent:marcus:main durationMs=456455 error=\"EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: .../534e56b0-2f9d-46f9-83b7-94e98b47e2a9.jsonl\""}

// SECOND INCIDENT — same pattern, different duration
{"diagnostic","1":"lane task error: lane=main durationMs=194036 error=\"EmbeddedAttemptSessionTakeoverError: ...\"}
{"diagnostic","1":"lane task error: lane=session:agent:marcus:main durationMs=194041 error=\"EmbeddedAttemptSessionTakeoverError: ...\"}
RAW_BUFFERClick to expand / collapse

Bug: EmbeddedAttemptSessionTakeoverError kills active session when Control UI accesses it

OpenClaw version: 2026.5.19-beta.1 (ba9034b) Gateway: running Affected agent(s): agent:marcus:main Channel: webchat / Control UI First seen: 2026-05-20 12:20 UTC Last seen: 2026-05-20 12:47 UTC


Description

When an embedded agent session is actively running (mid-model-call), if a second client (e.g. Control UI via webchat) accesses the same session — even read-only operations like sessions.list or chat.history — the embedded session is killed by EmbeddedAttemptSessionTakeoverError. The session file changes while the embedded prompt lock is released, triggering the takeover guard, which terminates the running lane task.

Expected: Active sessions should not be killed when another client reads session state. Actual: Any client access to a session with an active embedded run causes fatal takeover error.


Steps to Reproduce

  1. Have an embedded agent session (agent:marcus:main) actively running a model call
  2. While the call is in progress, a second client connects and accesses the same session (opens Control UI, runs sessions.list, or reads chat.history)
  3. The second client's access modifies the session file
  4. The embedded session's prompt lock is released during the model call
  5. When control returns, the session detects the file was modified externally
  6. EmbeddedAttemptSessionTakeoverError fires and kills the lane task

Frequency: Every time this happens — reproducible.


Expected Behavior

  1. Read-only client access to a session should not kill an active embedded run
  2. If the active session must be locked, the second client should be queued or receive a busy signal, not silently corrupt the embedded run's state
  3. No fatal error should result from a concurrent read by another client

Actual Behavior

  1. Session runs for minutes (194–456 seconds observed)
  2. Control UI connects as second client and reads session state (sessions.list, chat.history, etc.)
  3. EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released fires on both lane=main and lane=session:agent:marcus:main
  4. Lane task is killed with fatal error
  5. User sees Followup agent failed before reply: session file changed while embedded prompt lock was released
  6. No graceful handling — session dies immediately

Environment

FieldValue
OSLinux 7.0.0-15-generic (x64)
Node.jsv24.15.0
OpenClaw2026.5.19-beta.1 (ba9034b)
Install location/usr/local/bin/openclaw
Gateway bindloopback (127.0.0.1:18789)
Providerminimax
Modelminimax/MiniMax-M2.7

Relevant Logs

// AGENT RUNNING — long model call in progress
{"diagnostic","1":"long-running session: sessionId=534e56b0... sessionKey=agent:marcus:main state=processing age=146s ..."}


// WEBSOCKET DISCONNECT (first client)
{"gateway/ws","1":"webchat disconnected code=1001 reason=n/a conn=95448759..."}


// SECOND CLIENT (Control UI) IMMEDIATELY RECONNECTS AND READS SESSION STATE
{"gateway/ws","1":"webchat connected conn=4fdbed1e... remote=127.0.0.1 client=openclaw-control-ui webchat vcontrol-ui"}
{"gateway/ws","1":"⇄ res ✓ agents.list 162ms conn=4fdbed1e..."}
{"gateway/ws","1":"⇄ res ✓ chat.history 148ms conn=4fdbed1e..."}
{"gateway/ws","1":"⇄ res ✓ sessions.list 256ms conn=4fdbed1e..."}

// EMBEDDED SESSION KILLED — session file changed while lock released
{"diagnostic","1":"lane task error: lane=main durationMs=456451 error=\"EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: .../534e56b0-2f9d-46f9-83b7-94e98b47e2a9.jsonl\""}
{"diagnostic","1":"lane task error: lane=session:agent:marcus:main durationMs=456455 error=\"EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released: .../534e56b0-2f9d-46f9-83b7-94e98b47e2a9.jsonl\""}

// SECOND INCIDENT — same pattern, different duration
{"diagnostic","1":"lane task error: lane=main durationMs=194036 error=\"EmbeddedAttemptSessionTakeoverError: ...\"}
{"diagnostic","1":"lane task error: lane=session:agent:marcus:main durationMs=194041 error=\"EmbeddedAttemptSessionTakeoverError: ...\"}

Root Cause Analysis

The embedded agent runner releases the session file lock during model calls. When a second client (Control UI) accesses the same session mid-call, it modifies the session file. The takeover guard detects this modification and throws EmbeddedAttemptSessionTakeoverError, which is treated as fatal and kills the lane task.

The issue is in how session file locking interacts with lane scheduling:

  • Embedded run holds a prompt lock on the session file
  • During model calls, the lock is temporarily released
  • A second client's access during this window modifies the file
  • On return, the lock acquisition detects the modification and rejects the takeover
  • This is treated as a fatal lane error rather than a recoverable race condition

Severity

High — active agent sessions are killed by normal concurrent UI access. Any user who opens the Control UI while an agent is working on the same session will kill it. No graceful degradation.

Labels to apply

bug, type/gateway, severity/high

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…

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 kills active session when Control UI accesses it