Skip to content

fix: stop hidden helper agents posting raw reports to your chat - #206570

Merged
obviyus merged 3 commits into
openclaw:mainfrom
stealthybear:fix/subagent-wake-leak
Nov 29, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
stealthybear:fix/subagent-wake-leak

Conversation

@stealthybear

@stealthybear stealthybear commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

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.

@clawsweeper

clawsweeper Bot commented Nov 27, 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 docs Improvements or additions to documentation size: XS labels Nov 27, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Nov 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Suppresses automatic chat delivery of hidden helpers’ wake replies while preserving visible and conversation-bound sessions.

Example: A hidden helper runs sleep 30; echo done, yields, and replies HELPER RAW REPORT after completion.

  • Before: The Telegram DM receives HELPER RAW REPORT followed by PARENT SUMMARY.
  • After: The Telegram DM receives only PARENT SUMMARY; the parent still receives the helper’s result.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A useful, focused repair with real-channel evidence and distinct regression coverage; hosted validation awaits workflow approval.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Inspected Telegram before/after screenshots demonstrate the hidden helper’s exec-wake reply disappearing while the parent summary remains; that proof covers the earlier suppression logic retained here, while the new binding exemption has focused test coverage only.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users receive a hidden helper’s raw report before the parent’s summary, exposing internal notes and duplicating the result.
Reason: Restores the documented completion audience through a small change to the existing owner.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it provides a focused fix for a current delivery bug, with no actionable correctness findings.

Reviewed head: 49eba8ecf4f56f33924028a3ab212bf204fbd9bb

Before merge

  • Await maintainer action - Approve the GitHub Actions runs awaiting approval for head 49eba8e so required CI can execute.

Findings

None.

Agent review details

How this fits together

Background completions capture a session-event target, execute a follow-up turn, and route its output; hidden helpers separately return results through the subagent completion owner.

flowchart TD
  A[Background command completes] --> B[Session event target]
  B --> C[Helper wake turn]
  C --> D[Automatic chat delivery]
  C --> E[Subagent completion owner]
  E --> F[Parent agent]
  F --> G[User chat]
Loading

Technical review

Best possible solution:

Keep the focused suppression in the existing session-event target owner with visible and bound-session delivery preserved.

Do we have a high-confidence way to reproduce the issue?

Current-main source traces the inherited requester route from exec completion into unsuppressed event delivery, consistent with the contributor’s real Telegram reproduction.

Is this the best way to solve the issue?

The patch fixes the shared delivery decision without adding another execution path, and preserves the existing completion handoff and conversation-binding contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4fd7d7af0e74.

Provenance checked

  • Session-event automatic delivery keeps the original intent (753a7a5: Move immediate notifications into ordinary session execution while preserving originating routes and delivery opt-outs.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 753a7a5 adds src/auto-reply/reply/session-event-target.ts:118 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 753a7a57be10; files: src/auto-reply/reply/session-event-target.ts)
  • Ayaan Zaidi: Raw commit aa8b35b adds src/auto-reply/reply/session-event-target.ts:205 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: aa8b35bb20fd; files: src/auto-reply/reply/session-event-target.ts)

PR surface

Source +15, Tests +58, Docs +2. Total +75 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 16 1 +15
Tests 1 58 0 +58
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 76 1 +75

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.

Root-cause cluster

Relationship: same_root_cause
Canonical: #206556
Summary: This PR targets hidden-helper wake delivery; parent wording and empty-reply recovery are separate mechanisms.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • 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 (2 earlier review cycles)
  • reviewed 2026-11-27T10:30:47.441Z sha e3c8a49 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-27T11:02:15.663Z sha e3c8a49 :: blocked before merge. :: none

Reviewed November 29, 2026, 5:11 AM ET / 10:11 UTC (Revision 3).

@stealthybear

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Nov 27, 2026
@stealthybear stealthybear changed the title fix: stop a hidden subagent's raw report from also posting to your chat fix: stop hidden helper agents posting raw reports to your chat Nov 29, 2026
@stealthybear
stealthybear force-pushed the fix/subagent-wake-leak branch from e3c8a49 to 49eba8e Compare November 29, 2026 10:04
@stealthybear

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

subagent-capabilities reaches session-event-target through config/sessions, so the
static import formed a runtime import cycle (check:import-cycles). Load it in the
already-async capture, like the session entry reader next to it.
@obviyus

obviyus commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Live proof lines for c428bfa (Telegram Test Server DM; Discord QA Lab for the thread-bound control):

#206570 hidden subagent exec-wake reply leaks into requester chat
PR head c428bfac7aa6bb54c40deb8dd8f0891dd0dba019 (contributor 0ce511e9ff4b, 49eba8ecf4f5 + ours c428bfac7aa6); merge base 03cdb2cef17e
Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2cef17e) captures deliver from the producing run only; a hidden subagent's exec wake inherits the requester route with deliver unset, so session-event-delivery posts the wake reply to the requester chat.

Harness: proofs/206570/run-cell.sh (Telegram Test Server, telegram-e2e-userbot run-mock-sut-user-e2e.mjs, Convex lease, DM)
Model: proofs/206570/wake-mock.mjs (scripted model; spawn, exec background, sessions_yield, exec wake, announce and Telegram delivery are real)
Flow: DM -> parent sessions_spawn(mode=run, hidden) -> sessions_yield; child exec(background, "sleep 6; echo wake-output-$((40+2))") -> sessions_yield -> exec wake -> child replies HELPER_RAW_REPORT -> parent receives it -> replies PARENT_SUMMARY.

== Telegram DM, hidden helper (bug)
base 73940d31e759 run a3d6f418672c: DM got HELPER_RAW_REPORT @17.1s, PARENT_SUMMARY @18.9s; parent got helper result: yes
base 73940d31e759 run 3d98556c2e01: DM got HELPER_RAW_REPORT @12.8s, PARENT_SUMMARY @14.3s; parent got helper result: yes
base 03cdb2cef17e run 5befbecbb384: DM got HELPER_RAW_REPORT @12.9s, PARENT_SUMMARY @14.6s; parent got helper result: yes

== Telegram DM, hidden helper (fix)
cand c428bfac7aa6 run 0932d35507a2: DM got only PARENT_SUMMARY @14.2s; no HELPER_RAW_REPORT; child woke (exec output seen) and replied; parent got helper result: yes
cand c428bfac7aa6 run 693d9efc4611: DM got only PARENT_SUMMARY @14.3s; no HELPER_RAW_REPORT; child woke and replied; parent got helper result: yes
(earlier candidate ca5f8cafd2/016ac91b12, same fix logic, 3 more runs: only PARENT_SUMMARY each time, parent got helper result each time)

== Control: visible:true spawn still posts (Telegram DM)
base 73940d31e759 run d019ea952292: DM got PARENT_ACK @6.3s, HELPER_RAW_REPORT (visible child's wake reply) @13.3s
cand c428bfac7aa6 run 3ffa33d5a8d6: DM got PARENT_ACK @16.3s, HELPER_RAW_REPORT (visible child's wake reply) @22.3s

== Control: thread-bound subagent (active binding) keeps replying in its thread
Telegram cannot host this case: Telegram's binding placement is "current", so sessions_spawn offers no thread=true there (src/channels/conversation-resolution.ts supportsThreadBindingSpawn). Ran on Discord (QA Lab, Convex lease, mock-openai provider redirected to wake-mock.mjs) instead.
contributor head e3c8a49de0 (no binding exception) run 9265d1f07289 and cand c428bfac7aa6 runs b8276ca7bcc0, 4be10d0077a3: spawn(thread=true, mode=session) accepted ("final reply is delivered directly to the bound thread"), child exec(background) -> sessions_yield -> woke on exec output -> replied HELPER_RAW_REPORT.
Gap: the QA Lab recorder only observes the lease channel and driver-owned threads, and the SUT readback through the message tool was not available to the parent in that lane, so the thread message itself was not observed live. Thread delivery is proven by the unit boundary below.
Unit: src/auto-reply/reply/session-event-handoff.test.ts "routes a thread-bound subagent's event turns..." on e3c8a49de0 (hidden check without binding exception): FAIL "expected false to be undefined" (deliver forced false); on the binding-exception head: pass (3/3 cases).

== Parent still receives helper result (announce path untouched)
Every hidden run above (base and cand): the parent's settle turn input contained HELPER_RAW_REPORT (parentGotHelper=true) and it replied PARENT_SUMMARY.

== Checks on c428bfac7aa6
ocx test (session-event-handoff + 12 importers of session-event-target): 4 shards, 151 tests passed
check:import-cycles: 0 runtime cycles (contributor head had 1: subagent-capabilities -> config/sessions -> ... -> session-event-target -> subagent-capabilities; fixed by c428bfac7aa6)
check:changed dead export scan: 2 findings in untouched files (src/plugins/plugin-native-admission-state.ts, src/update/gateway-trial.ts), inherited from main
local ClawSweeper review: <review>/c428bfac7aa6.md, "patch is correct", no findings

@obviyus
obviyus merged commit 2a428f2 into openclaw:main Nov 29, 2026
123 of 125 checks passed
@obviyus

obviyus commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Landed in 2a428f2. Thanks @stealthybear for the report, the live repro and the fix, and @Nocha12 for #206708 and the active-binding exception from #206709. A hidden helper agent's wake reply now goes only to its parent, so you see one summary instead of the helper's raw report plus the summary. Visible spawns, thread-bound subagents and persistent ACP sessions still reply in their own conversation.

github-actions Bot pushed a commit to yun7764285/openclaw that referenced this pull request Nov 29, 2026
…570)

Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2cef17) 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 73940d31e75 (2 runs), 03cdb2cef17 (1 run) | yes, every run | yes | yes |
| this PR c428bfac7aa (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/openclaw#206570 (comment). Local review on c428bfac7aa: 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]>
github-actions Bot pushed a commit to jonasbkk1188/openclaw that referenced this pull request Nov 29, 2026
…570)

Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2cef17) 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 73940d31e75 (2 runs), 03cdb2cef17 (1 run) | yes, every run | yes | yes |
| this PR c428bfac7aa (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/openclaw#206570 (comment). Local review on c428bfac7aa: 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]>
github-actions Bot pushed a commit to tbohda2025/openclaw that referenced this pull request Nov 29, 2026
…570)

Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2cef17) 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 73940d31e75 (2 runs), 03cdb2cef17 (1 run) | yes, every run | yes | yes |
| this PR c428bfac7aa (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/openclaw#206570 (comment). Local review on c428bfac7aa: 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. 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: S status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

2 participants