Repository navigation
fix(subagents): completion review no longer repeats a result the user already saw - #198204
dixie-cooperation wants to merge 2 commits into
Conversation
…y delivered The completion review instruction only skipped results already visible "in this same turn", but a completion announce always runs as a new requester turn, so results the subagent or parent had already sent through the message tool were repeated, including their files. Name the real condition: anything already delivered earlier in the conversation is not repeated or re-attached.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. What this changesThis PR tells completion-review turns to avoid repeating text and files already delivered earlier in the conversation. Example: A WebChat parent displays report-a1.md and chart-a1.png before its background subagent finishes.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains This PR makes a useful, focused correction to completion-review guidance; no actionable patch defects were found, and the remaining merge gate is approval and completion of CI. Priority: P2 Before merge
FindingsNone. Agent review detailsHow this fits togetherThe subagent announcement owner turns completed child results into requester review context, which the parent consumes to continue work or produce a user-facing update. flowchart TD
A[Child result] --> B[Announcement owner]
B --> C[Completion review instruction]
C --> D[Requester parent]
E[Conversation history] --> D
D --> F[New information or brief confirmation]
Technical reviewBest possible solution: Keep the correction in the existing announcement instruction and complete the required CI before merging. Do we have a high-confidence way to reproduce the issue? Source shows the same-turn restriction on a completion path that can start a later requester turn, and the supplied base screenshot shows duplication; no target code was executed during this review. Is this the best way to solve the issue? The one-line correction is the smallest complete fix for the demonstrated prompt defect and preserves the existing outcome-review and delivery owners. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3bd03dafb94c. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource 0. Total 0 across 1 file. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
Reviewed November 13, 2026, 2:20 PM ET / 19:20 UTC (Revision 2). |
|
@clawsweeper re-review
|
|
🦞👀 Re-review progress:
|
) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2c) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes #206556 Fixes #206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for #206708 and for #206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 73940d3 (2 runs), 03cdb2c (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: #206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: #168227, #198204, #200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2c) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes #206556 Fixes #206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for #206708 and for #206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 73940d3 (2 runs), 03cdb2c (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: #206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: #168227, #198204, #200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]> Follow-up scan: 34d4f8f improve: list Docker streams and flag unconfirmed cleanup in Doctor (#201292); 21786f6 refactor(ui): stop sending 28 additional unused labels to translators (#207982); 9cec330 refactor(workboard): group session tiles without rescanning each column (#207380); 16a2d4b refactor(ui): lowercase log search text only once (#207383). Other hits are not required by this focused beta.2 fix. (cherry picked from commit 2a428f2) Co-authored-by: RomneyDa <[email protected]>
) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2c) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes #206556 Fixes #206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for #206708 and for #206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 73940d3 (2 runs), 03cdb2c (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: #206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: #168227, #198204, #200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2a428f2) Release adaptation: Suppress only hidden unbound helper events at the stable target capture; honor explicit delivery restrictions, visible sessions, active bindings, and the existing scheduled/requester custody. Companion audit: PR #206570 uses existing binding and spawn classifiers. Resume the stopped cherry-pick at the stable agent-run registry import anchor without importing main-only authority handlers. Co-authored-by: RomneyDa <[email protected]>
…claw#206570) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 7e9542f) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes openclaw#206556 Fixes openclaw#206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for openclaw#206708 and for openclaw#206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 2877834 (2 runs), 7e9542f (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: openclaw#206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: openclaw#168227, openclaw#198204, openclaw#200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: when a subagent's completion reaches an idle parent as a new turn, the parent can send the subagent's result (text and images) to the user a second time, even though the user already saw that result earlier in the conversation.
User Impact
User impact: if the user already received a subagent's result before its completion arrives, the completion turn no longer repeats the same text or re-attaches the same files. This happens, for example, when the parent showed the result on request while the subagent was still finishing, or when the result was already sent with the
messagetool. The parent confirms in at most one short sentence. Observed on WebChat with a Claude CLI parent.Why This Change Was Made
The default completion review instruction in
buildAnnounceReplyInstructionsaid:subagent-announce-direct-delivery.tshands a completion to the requester in one of two ways:This PR targets the second case. The instruction now says to send only what the user has not seen yet. If the result's text or files were already delivered earlier in this conversation, by the parent or by the subagent, the parent must not repeat them or re-attach the files. At most it confirms in one short sentence. Steered completions receive the same text, and anything already shown in the running turn still counts as seen.
This PR deliberately does not reintroduce
NO_REPLYguidance into the completion instruction. #162567 removed internal silence guidance so that silence could not hide unfinished work, and the existing failure-findings test still asserts the token is absent. The generic system prompt's silent-reply rule still applies when the model has nothing to add. On this path, a silent reply is already safe:deliverSubagentAnnouncementpassessourceTool: "subagent_announce", andsubagent-announce-direct-response.tssettles a successful, non-yieldedsubagent_announcecompletion without a visible payload as delivered.buildAnnounceReplyInstructionhas a single caller. Private (completionTarget: "parent"), nested-subagent andsubagent_settlecompletions use their own instructions and are unchanged.The change is the one-line instruction text in
subagent-announce.ts. The wording-only test from the first revision has been removed.Evidence
Live Gateway A/B with a real model. Each trial ran in a fresh WebChat (Control UI) session, with the same prompts for before and after.
2026.11.3) and run with an isolated state dir and config, on loopback, with no external channels and default tool policy.anthropic/claude-sonnet-5through theclaude-cliruntime (Claude Code 2.1.280).91046f7bb, after = this branch. Both runs used one build. For the before run, the one changed literal in the builtsubagent-announcechunk was restored to the base text, and the Gateway was restarted. That literal is the only non-test difference between the base and this branch.Each trial:
sessions_spawn, default completion delivery). The subagent gets a fixed task: writereport-<id>.md, renderchart-<id>.png, runsleep 180, then return the report and chart as its result. The parent spawns it and ends its turn.Measurement comes from the parent session's
chat.historyand covers the completion turn only:Before (base), completion turn repeats the report and the chart:
After (this PR), completion turn confirms in one sentence:
Limits of this run:
MEDIA:line in the middle of the reply, followed by more text, and the line stayed as raw text instead of becoming an attachment. In both, the completion turn repeated nothing, so the user never saw the chart image. That is a separate media-directive issue and shows that the fix relies on the parent's view of what was delivered.messagetool by default (SUBAGENT_TOOL_DENY_ALWAYSinagent-tools.policy.ts), so this run covers a result shown earlier by the parent. A subagent that sends its result itself (a visible spawned session, or a policy that allowsmessage) goes through the same instruction, but that variant was not run live.Tests and checks:
pnpm test src/agents/subagents/announce/subagent-announce.format.e2e.test.ts --maxWorkers=1: 30 passed (30). This includes the existing failure-findings case that assertsNO_REPLYstays out of the completion context.deliverSubagentAnnouncement(not committed) confirmed that a silent requester result for asubagent_announcecompletion settles asdelivered: trueon both a WebChat session origin and a Telegram route.git diff --check: clean.