Skip to content

[Bug]: Subagent announce 3x duplicate still reproduces on 2026.6.1 release + Telegram — #89812 only fixes outbound/deliver path, not subagent-announce-delivery #91527

Closed

Description

@zackchiutw

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

  1. From a Telegram DM parent session, call sessions_spawn(taskName="…", mode="run") with a long-running subagent task
  2. Parent calls sessions_yield to wait for the auto-announce
  3. 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)
  4. Subagent completes; gateway tries to inject the final text into the parent session
  5. Inject throws EmbeddedPromptLockFileChangedError because the parent jsonl changed while the embedded prompt lock was released
  6. Gateway's announce retry mechanism (in subagent-registry-dq-LC-2-.js:1037, maxAnnounceRetryCount: 3) fires 3 times with exponential backoff
  7. 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 (runtime subagent-announce-delivery-DhVEJzi6.js)
  • src/agents/subagent-registry-lifecycle.ts (runtime subagent-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

Suggested fix (mirroring #89812's pattern)

Either:

  1. Add EmbeddedPromptLockFileChangedError / "session file changed while embedded prompt lock was released" to PERMANENT_ANNOUNCE_DELIVERY_ERROR_PATTERNS in the announce-delivery module, so the lock race stops triggering retries at all.

  2. Or add an idempotency token check before each announce retry, mirroring what deliverOutboundPayloadsCore now does: if the outbound send already succeeded in a prior attempt, the retry must not re-send. A lastDeliveredOutboundAt / outboundDeliveryId field on the announce entry, set when [telegram] outbound send ok is 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.

Activity

  1. clawsweeper commented on Jun 8, 2026

    @clawsweeper
    Contributor

    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: canonical
    Canonical: #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:

    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:

    • The live Telegram race was not rerun in this read-only review; source evidence and reporter logs are strong, but transport proof still belongs on the fixing PR.
    • The linked PR is still open and marked as needing stronger real behavior proof, so closing this issue before merge would hide active work.

    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:

    Likely related people:

    • vincentkoc: Current blame for the announce classifier/retry snapshot points to Vincent Koc, and file history shows repeated recent subagent lifecycle and duplicate-announce work in adjacent paths. (role: recent area contributor; confidence: high; commits: 63fdc57b3ac2, 48042c3875, 8ad0ca309e84; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce.ts, src/agents/subagent-registry-lifecycle.ts)
    • steipete: History shows Peter Steinberger carried the subagent announce delivery pipeline unification and later split/refactor work that defines the current owner boundary. (role: feature-history contributor; confidence: medium; commits: 4258a3307f5a, b75be0914491, b0d9d1d2dae8; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce.ts)
    • Takhoffman: History shows adjacent subagent queue routing, stale completion dedupe, and cleanup-hook work that interacts with announce retry and delivery bookkeeping. (role: adjacent delivery contributor; confidence: medium; commits: a2cc0630d2c1, 6eaff70b55, fee9d4cf37; files: src/agents/subagent-announce.ts, src/agents/subagent-registry-lifecycle.ts)
    • fsdwen: The open closing PR for this exact issue is authored by fsdwen and contains focused commits against the implicated announce delivery and lifecycle test paths. (role: active fix PR author; confidence: medium; commits: 2b32200f5bd7, e6350474879d, b456254af5dd; files: src/agents/subagent-announce-delivery.ts, src/agents/subagent-announce.ts, src/agents/subagent-registry-lifecycle.test.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    and removed
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    on Jun 9, 2026
  3. added
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    and removed
    clawsweeper:needs-live-reproClawSweeper needs live local, crabbox, or manual validation to confirm this issue.
    issue-rating: 🐚 platinum hermitGood issue quality with a plausible reproduction path needing some confirmation.
    on Jun 19, 2026
  4. locked as resolved and limited conversation to collaborators on Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions