Repository navigation
Description
Summary
#89995 was closed as "already implemented" because PR #89812 (commit 79896a24) wraps the post-delivery transcript mirror in try/catch inside deliverOutboundPayloadsCore. That fix is real, but it does not cover the subagent-announce delivery path. The same EmbeddedPromptLockFileChangedError: session file changed while embedded prompt lock was released still triggers 3× duplicate Telegram sends on the 2026.6.1 stable release (not just the 2026.6.1-beta.3 reported in #89995).
Environment
| OpenClaw | 2026.6.1 release (npm openclaw@2026.6.1) |
| Channel | Telegram (direct DM, accountId=writer, chatId=51406718) |
| OS | Linux 6.17.0-1024-oem (Ubuntu) |
| Node | v22.22.2 |
| Spawn pattern | sessions_spawn(taskName=..., mode="run") + sessions_yield |
| Reproducible | 100% on this setup (1/1 observed so far) |
Steps to reproduce
- From a Telegram DM parent session, call
sessions_spawn(taskName="…", mode="run")with a long-running subagent task - Parent calls
sessions_yieldto wait for the auto-announce - The parent session is concurrently being written by the parent's own turn maintenance (the deferred turn-maintenance lane queues around the same time as the subagent's completion event)
- Subagent completes; gateway tries to inject the final text into the parent session
- Inject throws
EmbeddedPromptLockFileChangedErrorbecause the parent jsonl changed while the embedded prompt lock was released - Gateway's announce retry mechanism (in
subagent-registry-dq-LC-2-.js:1037,maxAnnounceRetryCount: 3) fires 3 times with exponential backoff - Each retry independently triggers a Telegram outbound send → user receives 3 identical messages
Why PR #89812 is not sufficient
PR #89812 only modified:
src/infra/outbound/deliver.ts(+24, -8)src/infra/outbound/deliver.test.ts(+62, -1)
The fix wraps appendAssistantMessageToSessionTranscript(...) in try/catch so a mirror failure no longer fails the overall deliverOutboundPayloadsCore call. That stops the retry-on-mirror-failure path for the general outbound layer (matrix/telegram/etc. when an agent's reply is being sent to the user).
The subagent-announce path is a separate delivery module:
src/agents/subagent-announce-delivery.ts(runtimesubagent-announce-delivery-DhVEJzi6.js)src/agents/subagent-registry-lifecycle.ts(runtimesubagent-registry-dq-LC-2-.js, retry orchestration)
That path still classifies the lock-change error as retriable and has no idempotency check between the in-band delivery attempt and the external outbound send. So the bug reproduced on the 2026.6.1 stable release, not just on beta.
Evidence (local journalctl excerpt)
07:24:00.400 [MiniMax-M3] (subagent) ✅ 任務完成 …(child session output)…
07:24:22.754 [agent/embedded] [context-engine] deferred turn maintenance queued
lane=context-engine-turn-maintenance:agent:writer:telegram:direct:51406718
07:24:23.899 [telegram] outbound send ok accountId=writer chatId=51406718 messageId=2624
07:24:23.978 [warn] Subagent completion direct announce failed for run b434f673-…:
text completion direct delivery failed:
session file changed while embedded prompt lock was released:
/home/zackchiu/.openclaw/agents/writer/sessions/6512e51b-….jsonl
07:24:25.716 [telegram] outbound send ok messageId=2625
07:24:25.731 [warn] Subagent completion direct announce failed … (retry 2)
07:24:28.500 [telegram] outbound send ok messageId=2626
07:24:28.517 [warn] Subagent completion direct announce failed … (retry 3)
07:24:28.700 [warn] Subagent announce give up (retry-limit) retries=3 endedAgo=29s
User report from the parent: "你摘要網頁又連發三次一樣的訊息了" (2026-06-09 07:39 local).
Related issues / PRs
- EmbeddedPromptLockFileChangedError causes subagent announce to retry after message already delivered, resulting in duplicate messages #89995 — original report (closed as "already implemented" via PR fix(outbound): keep channel send durable when transcript mirror fails (#89626) #89812, but the fix doesn't cover the subagent-announce path; this is the issue I'm re-filing against)
- [Bug]: Sub-agent completion announce unreliable on Telegram — sometimes silent, sometimes delivers 3x duplicate #90103 — "Sub-agent completion announce unreliable on Telegram — sometimes silent, sometimes delivers 3x duplicate" (Pattern B matches exactly)
- Subagent announce completion timeout causes duplicate messages to user #41235 — "Subagent announce completion timeout causes duplicate messages to user" (same retry → duplicate pattern, gateway timeout instead of lock error)
- fix(subagents): prevent message_tool_only from swallowing subagent completion message (AI-assisted) #90041 —
fix(subagents): prevent message_tool_only from swallowing subagent completion message - fix(announce): durable in-process queue fallback for direct-pending handoffs #90144 —
fix(announce): durable in-process queue fallback for direct-pending handoffs - fix(agents): harden subagent announce retry and error handling #90561 —
fix(agents): harden subagent announce retry and error handling(most likely the right place to land a permanent/permanent classification of the lock error) - fix(agents): skip text-direct fallback for sessions_yield completions #91370 —
fix(agents): skip text-direct fallback for sessions_yield completions - fix(agents): preserve subagent wake delivery route #91381 —
fix(agents): preserve subagent wake delivery route
Suggested fix (mirroring #89812's pattern)
Either:
-
Add
EmbeddedPromptLockFileChangedError/ "session file changed while embedded prompt lock was released" toPERMANENT_ANNOUNCE_DELIVERY_ERROR_PATTERNSin the announce-delivery module, so the lock race stops triggering retries at all. -
Or add an idempotency token check before each announce retry, mirroring what
deliverOutboundPayloadsCorenow does: if the outbound send already succeeded in a prior attempt, the retry must not re-send. AlastDeliveredOutboundAt/outboundDeliveryIdfield on the announce entry, set when[telegram] outbound send okis logged, would do it.
Option 1 is the smaller, safer change and matches the suggestion in the original #89995 report.
Workaround (in our setup, until this lands)
agents.defaults.subagents.announceTimeoutMs: 0 and agent-side deduplication on (childRunId, 60s) for incoming completion events. Not great — the proper fix is upstream.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 8, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed June 21, 2026, 3:37 PM ET / 19:37 UTC.
Summary
Keep open: current main and v2026.6.9 still lack terminal handling for this subagent-announce lock-change path, and #92274 is the open closing candidate.
Reproducibility: yes. Current main has a high-confidence source reproduction path: the reported lock-change error is not terminal in the subagent announce path, direct announce returns failed, and cleanup retry remains capped at three attempts; I did not rerun the live Telegram race.
Root-cause cluster
Relationship:
canonicalCanonical: #91527
Summary: This issue is the canonical open report for the embedded prompt lock-change duplicate subagent announce path; the open linked PR is the active fix candidate.
Members:
fixed_by_candidate: fix(agents): classify embedded prompt lock error as permanent announce failure #92274 - Open PR uses closing syntax for this issue and changes the implicated subagent announce delivery path.superseded: EmbeddedPromptLockFileChangedError causes subagent announce to retry after message already delivered, resulting in duplicate messages #89995 - Earlier closed report describes the same lock-change duplicate announce symptom but was closed against the sibling outbound mirror fix.partial_overlap: fix(outbound): keep channel send durable when transcript mirror fails (#89626) #89812 - Merged PR fixed general outbound transcript mirror failures, not the separate subagent announce retry path.partial_overlap: Subagent completion announcements can be premature or duplicated after tool-use turns #80498 - Open issue tracks broader premature or duplicated subagent completion announcements beyond this exact lock-change failure.superseded: fix(agents): classify embedded prompt lock-changed error as permanent announce failure (fixes #91527) #91641 - Closed earlier regex-only PR targeted this issue before the current open PR added the send-evidence and lifecycle propagation shape.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
Do not queue a new repair job because the open linked PR already owns the fix path and is awaiting proof or maintainer review.
Review details
Best possible solution:
Land #92274 or an equivalent reviewed fix that treats post-send lock-change failures as terminal and prevents cleanup retry from resending the completion.
Do we have a high-confidence way to reproduce the issue?
Yes. Current main has a high-confidence source reproduction path: the reported lock-change error is not terminal in the subagent announce path, direct announce returns failed, and cleanup retry remains capped at three attempts; I did not rerun the live Telegram race.
Is this the best way to solve the issue?
Yes. The best current path is to review and land the linked focused PR, or an equivalent patch in the subagent announce delivery/cleanup boundary, rather than opening a competing fix.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 6daf9307e0b9.
Label changes
Label justifications:
P1: The issue reports a broken Telegram subagent workflow where one completion can be sent three times to a real user.impact:message-loss: The affected announce retry path can duplicate user-visible completion messages after a send already occurred.impact:session-state: The trigger is a parent session transcript lock-change race during subagent completion injection.Evidence reviewed
What I checked:
AGENTS.md:1, 6daf9307e0b9)session file changed while embedded prompt lock was releasedmessage. (src/agents/subagent-announce-delivery.ts:371, 6daf9307e0b9)delivered: falsewith the summarized error and no terminal marker, so lifecycle bookkeeping does not credit the already-sent completion. (src/agents/subagent-announce-delivery.ts:1637, 6daf9307e0b9)runSubagentAnnounceFlowsetsdidAnnounce = delivery.delivered, so a post-send failure is not counted as announced on current main. (src/agents/subagent-announce.ts:582, 6daf9307e0b9)src/agents/subagent-registry-helpers.ts:40, 6daf9307e0b9)src/agents/subagent-announce-delivery.ts:371, c645ec4555c0)Likely related people:
src/agents/subagent-announce-delivery.ts,src/agents/subagent-announce.ts,src/agents/subagent-registry-lifecycle.ts)src/agents/subagent-announce-delivery.ts,src/agents/subagent-announce.ts)src/agents/subagent-announce.ts,src/agents/subagent-registry-lifecycle.ts)src/agents/subagent-announce-delivery.ts,src/agents/subagent-announce.ts,src/agents/subagent-registry-lifecycle.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.fix(agents): classify embedded prompt lock error as permanent announc…
fix(agents): add structured send evidence for session-file-changed an…