Skip to content

fix: stop hidden subagents from replying straight into the requester's chat - #206709

Closed
Nocha12 wants to merge 5 commits into
openclaw:mainfrom
Nocha12:fix/W-20261127-1101-ended-subagent-direct-delivery
Closed

Nocha12 wants to merge 5 commits into
openclaw:mainfrom
Nocha12:fix/W-20261127-1101-ended-subagent-direct-delivery

Conversation

@Nocha12

@Nocha12 Nocha12 commented Nov 27, 2026

Copy link
Copy Markdown

Closes #206708

What Problem This Solves

When a hidden subagent's background command or tool handoff finishes after its turn, the wake-up turn replies straight into the chat of the person who started the parent task. Hidden workers are supposed to report through their parent, so users get raw worker messages in their DM, often duplicated with the parent's own report.

User Impact

Background follow-ups from hidden subagents no longer appear directly in the requester's chat; the wake turn still runs and its reply stays in the worker session. Visible spawned sessions (sessions_spawn with visible=true), thread-bound subagents and persistent ACP sessions with an active conversation binding, and ordinary chat sessions behave as before. No configuration or migration needed.

Why This Change Was Made

Hidden subagents inherit the requester's delivery route at spawn, and the session-event target captured for a wake turn left deliver unset, so the inherited route was used. The target capture now sets deliver: false only when the caller did not choose a value, the session is a subagent envelope that is not a visible spawned session (existing helpers in subagent-capabilities, now given cfg), and the session has no active conversation binding (the same binding listing bound delivery uses), so thread-bound workers keep replying in their own thread. An explicit deliver from the caller still wins, and the existing merge rule (any retained target with deliver: false keeps the batch silent) is unchanged.

Evidence

  • New focused test session-event-hidden-subagent-delivery.test.ts drives a real background wake through admission and delivery planning with a synthetic model, for four destinations: hidden subagent, hidden dashboard child, visible spawned session, ordinary session. It is registered in the database-worker core list like the other session-event tests.
  • With the fix: new test 4/4 and session-event-handoff.test.ts pass (26 tests total).
  • With the fix reverted: the two hidden cases fail (delivered: true, reply routed to the requester chat); visible and ordinary cases still pass.
  • A fifth case, a thread-bound subagent with an active binding, keeps delivering; removing the binding check fails only that case.
  • pnpm tsgo:core passes.
  • Not run: full test suite, full build, live channel reproduction after the patch.

Known limitation

If a hidden worker's run has already ended, nothing re-announces the wake turn's reply to the parent, so that follow-up is only visible in the worker transcript. This PR stops the leak into the requester's chat; routing ended-worker wake output into the announce chain would be a follow-up. Separately, bash-process-durable-notify.ts already disables exec-exit notifications for all hidden envelopes without a binding exemption (pre-existing, unchanged here).

Hidden subagent sessions inherit the requester's delivery route. A background
wake turn (exec/tool handoff) in such a session replied directly into that chat,
bypassing the announce chain. Capture deliver:false for hidden subagent
envelopes; visible spawned and ordinary sessions keep direct delivery.
… thread

Only silence direct wake delivery for hidden workers with no active
conversation binding; thread-bound subagents and persistent ACP sessions
are addressed by the user directly. Pass cfg to the envelope checks.
@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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. labels Nov 27, 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. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. 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 27, 2026
@clawsweeper

clawsweeper Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

Suppresses automatic chat delivery of hidden-worker wake replies while preserving visible, ordinary, and actively bound sessions.

Example: A hidden worker replies “Worker follow-up result” after a background completion.

  • Before: The reply is sent directly to the requester’s Telegram chat.
  • After: Automatic delivery is suppressed; the reply remains in the worker session.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) A focused partial repair with no definite introduced code defect, but required real-behavior proof is absent and its remaining delivery outcome needs an owner decision.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Needs a maintainer decision · Fix scope: Partial
User problem: Internal worker replies reach the requester’s chat directly and can duplicate the parent’s report.
Reason: The suppression restores the documented audience, but accepting transcript-only results after worker completion is an unresolved partial-fix choice.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR addresses a current delivery bug and adds distinct bound-session handling, but its acknowledged transcript-only outcome for ended workers needs a scope decision.

Reviewed head: 4ec85343b756ba1f3fdbc815e4fa577c5962d1f2
Owner decision: Required. See Decision needed.

Decision needed

  • Question: May this land as a partial delivery-suppression repair while ended-worker parent re-announcement remains separate?
  • Recommendation: Accept a scoped partial repair: Restore the hidden-worker audience boundary, use Related instead of closing the linked issue, and retain a focused follow-up for ended-worker parent delivery.
  • Why: The linked issue requires results to reach the parent, but the PR acknowledges that already-ended workers can leave follow-up results only in their transcripts, and no owner has accepted that scope.

Before merge

  • Add real behavior proof - This head supplies real event-admission tests with synthetic model execution and mocked transport, but no shipped-Gateway or channel result; the earlier PR’s Telegram evidence does not exercise this head’s binding exemption, so the contributor must supply focused runtime proof with IPs, keys, phone numbers, and non-public endpoints redacted. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Await maintainer action - Approve the exact-head GitHub Actions workflows awaiting approval so required CI can execute.

Findings

None.

Tests

  • Missing end-to-end proof: Provide redacted shipped-Gateway evidence on this head showing a hidden-worker wake avoids direct chat delivery, its result reaches the parent when expected, and bound-session replies retain their destination.
Agent review details

How this fits together

Background completions capture a session-event target, execute a wake turn, and use its delivery policy to control external replies; parent completion handoff is separate.

flowchart TD
  A[Background completion] --> B[Capture event target]
  B --> C[Execute worker wake]
  C --> D[Worker transcript]
  C --> E[Automatic chat delivery]
  B --> E
  D --> F[Existing parent completion handoff]
  F --> G[Parent summary]
Loading

Technical review

Best possible solution:

Consolidate the overlapping capture-policy fixes while preserving interactive delivery and explicitly tracking any remaining ended-worker parent handoff.

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

Current-main target capture and delivery establish the inherited-route failure, supported by the linked release report; this review executed no target code.

Is this the best way to solve the issue?

Target capture is the smallest existing owner for suppression, but this is only a partial solution to the linked issue’s parent-delivery requirement.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 89425fd75d4e.

Provenance checked

  • Session-event delivery policy keeps the original intent (753a7a5: Run background notifications through ordinary session execution while retaining originating routes and automatic-delivery opt-out.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 753a7a5 adds src/auto-reply/reply/session-event-target.ts:110 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)

PR surface

Source +16, Tests +150. Total +166 across 3 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 1 16 0 +16
Tests 2 150 0 +150
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 166 0 +166

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: fixed_by_candidate
Canonical: #206556
Summary: The reports and both open fixes identify the same missing hidden-worker suppression at session-event capture.

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:

  • merge-risk: 🚨 message-delivery: The change intentionally suppresses external replies, and the acknowledged ended-worker case has no replacement parent announcement.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Provide the focused shipped-Gateway proof described above.
  • Resolve whether ended-worker parent delivery is part of this PR or a separately tracked partial-fix follow-up.

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.

Reviewed November 27, 2026, 9:00 AM ET / 14:00 UTC.

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

obviyus commented Nov 29, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Nocha12. #206570 (opened earlier for the same bug) landed in 2a428f2 and carries your active-binding exception, so thread-bound subagents and persistent ACP sessions keep replying in their own conversation. You're credited in the landed PR. Closing this one as covered.

@obviyus obviyus closed this Nov 29, 2026
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

impact:message-loss Channel message delivery can be lost, duplicated, or misrouted. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hidden subagent background follow-ups reply directly into the requester's chat

2 participants