Summary
When a subagent completes and triggers an announce back to the requester session, if the main session file is concurrently being written (e.g., main agent is sending a Feishu message at the same moment), the announce throws EmbeddedPromptLockFileChangedError and retries — even though the message was already successfully delivered. This causes duplicate messages in the channel.
Steps to Reproduce
- Spawn a subagent via
sessions_spawn
- Subagent completes and triggers announce to main session
- At the same moment, main agent is writing to the session file (e.g., delivering a reply to the user)
- Announce throws
session file changed while embedded prompt lock was released
- Announce retries 3 times (5s / 10s / 20s intervals)
- Each retry successfully sends the message → user receives 3 identical duplicate messages
Log Evidence
feishu: sendText target=user:ou_xxx, textLength=25 ← message sent successfully
[warn] Subagent completion direct announce failed: text completion direct delivery failed: session file changed while embedded prompt lock was released: /path/to/session.jsonl
feishu: sendText target=user:ou_xxx, textLength=25 ← retry #1, duplicate sent
[warn] Subagent completion direct announce failed: ... session file changed ...
feishu: sendText target=user:ou_xxx, textLength=25 ← retry #2, duplicate sent
[warn] Subagent announce give up (retry-limit) run=xxx
Root Cause
In subagent-announce-delivery.js, the error session file changed while embedded prompt lock was released (thrown as EmbeddedPromptLockFileChangedError) is not classified in either:
TRANSIENT_ANNOUNCE_DELIVERY_ERROR_PATTERNS
PERMANENT_ANNOUNCE_DELIVERY_ERROR_PATTERNS
Despite this, the announce still retries. Critically, no idempotency check is performed before retrying — the code does not verify whether the message was already delivered before attempting to send again.
Suggested Fix
Either:
- Add
/session file changed while embedded prompt lock was released/i to PERMANENT_ANNOUNCE_DELIVERY_ERROR_PATTERNS to prevent retry after this error
- Record a delivery idempotency token when
sendText succeeds, and check it before each retry to avoid duplicate delivery
Environment
- OpenClaw version: 2026.6.1-beta.3 (3b53e2c)
- Channel: Feishu (via
@larksuite/openclaw-lark plugin v2026.5.20)
- OS: Darwin 25.3.0 (arm64)
- Node: v24.14.1
- Reproducible: consistently, every subagent announce when main session has concurrent write activity
Summary
When a subagent completes and triggers an announce back to the requester session, if the main session file is concurrently being written (e.g., main agent is sending a Feishu message at the same moment), the announce throws
EmbeddedPromptLockFileChangedErrorand retries — even though the message was already successfully delivered. This causes duplicate messages in the channel.Steps to Reproduce
sessions_spawnsession file changed while embedded prompt lock was releasedLog Evidence
Root Cause
In
subagent-announce-delivery.js, the errorsession file changed while embedded prompt lock was released(thrown asEmbeddedPromptLockFileChangedError) is not classified in either:TRANSIENT_ANNOUNCE_DELIVERY_ERROR_PATTERNSPERMANENT_ANNOUNCE_DELIVERY_ERROR_PATTERNSDespite this, the announce still retries. Critically, no idempotency check is performed before retrying — the code does not verify whether the message was already delivered before attempting to send again.
Suggested Fix
Either:
/session file changed while embedded prompt lock was released/itoPERMANENT_ANNOUNCE_DELIVERY_ERROR_PATTERNSto prevent retry after this errorsendTextsucceeds, and check it before each retry to avoid duplicate deliveryEnvironment
@larksuite/openclaw-larkplugin v2026.5.20)