Skip to content

fix(subagents): completion review no longer repeats a result the user already saw - #198204

Open
dixie-cooperation wants to merge 2 commits into
openclaw:mainfrom
dixie-cooperation:fix/subagent-announce-no-resend
Open

dixie-cooperation wants to merge 2 commits into
openclaw:mainfrom
dixie-cooperation:fix/subagent-announce-no-resend

Conversation

@dixie-cooperation

@dixie-cooperation dixie-cooperation commented Nov 13, 2026 •

Copy link
Copy Markdown

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 message tool. 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 buildAnnounceReplyInstruction said:

Otherwise send a truthful user-facing update unless this exact result is already visible to the user in this same turn.

subagent-announce-direct-delivery.ts hands a completion to the requester in one of two ways:

  • If the requester has a running turn, the completion is steered into that turn. There "in this same turn" can match, and this PR does not change that path.
  • If the requester is idle, the completion starts a new requester turn. Whatever the user already saw is then in an earlier turn, so the condition never matches. The result looks unseen, and the parent may repeat it.

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_REPLY guidance 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: deliverSubagentAnnouncement passes sourceTool: "subagent_announce", and subagent-announce-direct-response.ts settles a successful, non-yielded subagent_announce completion without a visible payload as delivered. buildAnnounceReplyInstruction has a single caller. Private (completionTarget: "parent"), nested-subagent and subagent_settle completions 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.

  • Gateway: built from source (2026.11.3) and run with an isolated state dir and config, on loopback, with no external channels and default tool policy.
  • Model: anthropic/claude-sonnet-5 through the claude-cli runtime (Claude Code 2.1.280).
  • Before = base 91046f7bb, after = this branch. Both runs used one build. For the before run, the one changed literal in the built subagent-announce chunk 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:

  1. The user asks for a fictional six-month sales report plus a PNG bar chart, made by a background subagent (sessions_spawn, default completion delivery). The subagent gets a fixed task: write report-<id>.md, render chart-<id>.png, run sleep 180, then return the report and chart as its result. The parent spawns it and ends its turn.
  2. Once both files exist and the parent is idle, the user writes: "Is it ready yet? report-.md and chart-.png are already in the workspace - please show me the report text and the chart image here now." The parent shows the full report and attaches the chart.
  3. The subagent then finishes. The parent is idle, so the completion runs as a later turn. In every trial it started 146–239 s after the turn-2 reply was recorded. No completion was steered.

Measurement comes from the parent session's chat.history and covers the completion turn only:

  • "report repeated" means at least 5 of the 6 monthly figures appear in the visible reply.
  • "chart re-attached" means the completion reply contains an image.
valid trials report repeated chart re-attached any repeat other completion replies
before (base) 12 2 3 3 7 confirmations of 1–3 sentences (one restates four headline figures), 2 silent
after (this PR) 12 0 0 0 12 confirmations of 1–2 sentences
  • Before, repeat example: "The subagent has now fully finished …, matching what I already showed you — no changes to the report or chart." This was followed by the full report table and the chart a second time.
  • After, typical reply: "Confirmed — the subagent finished all steps …, and it matches the report and chart I already shared with you above. Nothing new to add."

Before (base), completion turn repeats the report and the chart:

before

After (this PR), completion turn confirms in one sentence:

after

Limits of this run:

  • Two further after-trials are excluded from the table because the turn-2 precondition failed. The parent put its 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.
  • Model compliance is probabilistic. 3/12 vs 0/12 is a small sample and does not show the repeat can never happen.
  • Hidden subagents do not get the message tool by default (SUBAGENT_TOOL_DENY_ALWAYS in agent-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 allows message) 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 asserts NO_REPLY stays out of the completion context.
  • A local probe through deliverSubagentAnnouncement (not committed) confirmed that a silent requester result for a subagent_announce completion settles as delivered: true on both a WebChat session origin and a Telegram route.
  • git diff --check: clean.

…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.
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS labels Nov 13, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This 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.

  • Before: The later completion turn can repeat the full report and chart.
  • After: The completion turn confirms completion briefly without repeating the report or chart.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused correction with direct before/after behavior evidence and no actionable findings; exact-head CI still awaits workflow approval.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Inspected WebChat screenshots show a background completion repeating an earlier report and chart on the base and producing only a brief confirmation with the fix; the contributor identifies a live Gateway and claude-cli parent, resolving the prior review's proof gap for this scenario.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A later completion review repeats a report and attachments the user has already received.
Reason: Avoiding duplicate delivery is already the instruction's intent, and the correction preserves continued work on unfinished outcomes.

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
Reviewed head: 73737e17dda6bfb69c02bec94ca7f2b31272e934

Before merge

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • User-facing completion review instruction keeps the original intent (4f0541e: Require meaningful delegated outcomes and remove internal silence guidance while preserving verified delivery and owned continuations.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Tyler Yust: Raw commit b8f66c2 adds src/agents/subagent-announce.ts:342 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: b8f66c260db8; files: src/agents/subagent-announce.ts)

PR surface

Source 0. Total 0 across 1 file. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 1 1 0

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Repeated completion text and attachments create a bounded user-facing defect without preventing delivery of the original result.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: ⏳ waiting on maintainer: Only explicit maintainer approvals or decisions remain; merge is still blocked.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-11-13T09:56:34.741Z sha 79e3a8a :: needs real behavior proof before merge. :: none

Reviewed November 13, 2026, 2:20 PM ET / 19:20 UTC (Revision 2).

@dixie-cooperation dixie-cooperation changed the title fix(subagents): parent no longer resends a result the subagent already delivered fix(subagents): completion review no longer repeats a result the user already saw Nov 13, 2026
@dixie-cooperation

Copy link
Copy Markdown
Author

@clawsweeper re-review

  • Removed the wording-only test; the diff is now the one-line instruction change.
  • Added a live Gateway A/B: claude-cli parent on WebChat, completion arriving as a later turn after the user had already seen the report and chart. Base repeated the result in 3/12 trials, this branch in 0/12. Screenshots and method are in the PR body.
  • Narrowed the description: an active requester is steered and this PR leaves that path alone. The fix targets completions that start a later turn.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 13, 2026
obviyus added a commit that referenced this pull request Nov 29, 2026
)

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):

![Phone screenshots of the bot DM: the release posts HELPER RAW REPORT and PARENT SUMMARY, the fix posts only PARENT SUMMARY](https://raw.githubusercontent.com/stealthybear/openclaw/a9c8ba79ce9f4394d7a0df4f14fcfb46157985fa/real-before-after.png)

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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 29, 2026
)

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):

![Phone screenshots of the bot DM: the release posts HELPER RAW REPORT and PARENT SUMMARY, the fix posts only PARENT SUMMARY](https://raw.githubusercontent.com/stealthybear/openclaw/a9c8ba79ce9f4394d7a0df4f14fcfb46157985fa/real-before-after.png)

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]>
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
)

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):

![Phone screenshots of the bot DM: the release posts HELPER RAW REPORT and PARENT SUMMARY, the fix posts only PARENT SUMMARY](https://raw.githubusercontent.com/stealthybear/openclaw/a9c8ba79ce9f4394d7a0df4f14fcfb46157985fa/real-before-after.png)

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]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 30, 2026
…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):

![Phone screenshots of the bot DM: the release posts HELPER RAW REPORT and PARENT SUMMARY, the fix posts only PARENT SUMMARY](https://raw.githubusercontent.com/stealthybear/openclaw/a9c8ba79ce9f4394d7a0df4f14fcfb46157985fa/real-before-after.png)

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]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant