openclaw - 💡(How to fix) Fix EmbeddedAttemptSessionTakeoverError causes silent message loss when session lock released during API retries

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…
RAW_BUFFERClick to expand / collapse

Bug Description

When a model API (e.g., DeepSeek) experiences consecutive ECONNRESET errors, the gateway retries the request. During retries, the embedded prompt lock on the session file is released. If another message queues up and modifies the session file during this window, the original attempt detects a fingerprint mismatch and throws EmbeddedAttemptSessionTakeoverError:

session file changed while embedded prompt lock was released

This causes the reply to be silently dropped — the control panel shows a reply was generated, but the message never reaches the user (e.g., via Feishu). The gateway eventually falls back to a generic ⚠️ Something went wrong… message, but the original reply is lost.

Steps to Reproduce

  1. Model API intermittently returns ECONNRESET/timeout
  2. Start a conversation turn (embedded agent attempt acquires session lock)
  3. API fails → lock releases during retry → another incoming message modifies session file → original attempt resumes and detects fingerprint mismatch
  4. EmbeddedAttemptSessionTakeoverError thrown, reply never delivered

Observed Behavior

  • Message silently lost (no delivery to chat channel)
  • Can be delayed by days (message reappears after gateway restart)
  • Often accompanied by Feishu API 502 errors (separate issue)
  • Log pattern: EmbeddedAttemptSessionTakeoverError: session file changed while embedded prompt lock was released

Expected Behavior

The session lock should either:

  1. Automatically retry (with backoff) when takeover is detected, OR
  2. Queue the reply for later delivery instead of silently dropping it

Environment

  • OpenClaw version: 2026.5.22
  • Model: deepseek/deepseek-v4-pro
  • Channel: feishu
  • Location: dist/selection-hR-AeOeU.js (EmbeddedAttemptSessionTakeoverError class)

Proposed Fix

The noopLock fallback in the current implementation discards the lock acquisition without retry. A simple retry loop (e.g., 3 attempts with exponential backoff on fingerprint mismatch) would significantly reduce message loss.

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 EmbeddedAttemptSessionTakeoverError causes silent message loss when session lock released during API retries