Repository navigation
fix(agents): keep a yielded subagent's command wakes on its task after a follow-up run - #200046
Conversation
…r a follow-up run
A paused subagent task continues under a new run id each time an exit wake
resumes it. The commands that the earlier run started kept that run as their
owner. When one of them exited after a later run had yielded, its wake named
the retired run, so reply admission did not continue the task. The turn ran
as a separate follow-up, the task row stayed paused, and the child's final
reply never reached its requester. The later run also could not yield on
those commands ("its exit cannot resume this run").
Adoption of a paused row now moves the running commands of the retired run
to the new run, the same way it remaps the settle batch.
Co-authored-by: obviyus <[email protected]>
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR transfers running commands to the successor run when a follow-up continues a yielded subagent task. Example: A child starts A for 15 seconds and B for 50 seconds; A resumes it as run 2, which starts C for 70 seconds and yields.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR fixes a current task-continuation defect, and no blocking code findings remain. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe process registry tracks background commands; subagent adoption transfers task ownership, and exec completion provenance tells reply admission which paused task to continue. flowchart TD
A[Child starts background commands] --> B[Child yields]
B --> C[First exit resumes child]
C --> D[Registry adopts successor run]
D --> E[Running commands transfer ownership]
E --> F[Later exit names successor]
F --> G[Task resumes and parent receives result]
Technical reviewBest possible solution: Keep running-command ownership aligned with the adopted task through the existing process registry operation at committed task handoff. Do we have a high-confidence way to reproduce the issue? The overlapping-command sequence has a clear source-level failure path and supplied base/head Gateway results; this read-only review did not independently execute it. Is this the best way to solve the issue? The patch repairs the stale ownership value at its existing owner, preserves the paused-task admission check, and adds one focused adoption regression without new state or competing delivery paths. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 84a378cfe2df. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +18, Tests +51, Docs +4. Total +73 across 6 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 16, 2026, 4:34 AM ET / 09:34 UTC. |
|
Landed in 317f065.
|
…#200097) ## What Problem This Solves Background commands, `sessions_yield` waits and exec-exit wakes were owned by the run that started them. A run id names one attempt, and a chat gets a new one on every turn. So every follow-up run lost the commands of the earlier runs: - A later turn could not yield on a command that an earlier turn started. `listYieldAwaitableExecs(runId)` matched `originRunId === runId`, so `sessions_yield` returned `nothing_pending` and the model started to poll. - A paused subagent task continued only when the wake named the paused run. #200046 patched one caller of this: it moved the running commands to the new run (`moveRunningSessionsToRun`). - Child completions compared the captured requester session id and lifecycle revision. After a reset or a compaction successor, a private completion was withheld with "Subagent results from the previous session were not delivered". ## Why This Change Was Made The bug class is "address work by an id that changes". The chat's session key is the only id that survives edits, resets, compaction and follow-up runs. This PR makes the key the owner: - `listYieldAwaitableExecs`, `awaitExecsForYield` and `openExecYieldResume` are keyed by the chat: agent id plus session key, so a raw shared key such as `global` stays separate per agent. A yield awaits every wake-armed command of the chat, including commands from earlier runs. - Reply admission continues the task that is paused in the chat, whichever run paused it (`continuesPausedTask` replaces `pausedRunId`). - Child and harness completions, and the failure notice of a required completion, go to the requester chat as it is now. The reads of `completionRequesterSessionId` / `LifecycleRevision`, the settle-receipt exact compare, the collector and `agents_wait` incarnation filters, and the reset replacement notice are deleted. - Deleted: `ProcessSession.originRunId`, `moveRunningSessionsToRun` (the #200046 patch), `matchesSubagentRequesterSession`, `recordRequesterReplacementNotice`, `listCollectorRunsForRequesterIncarnation` (now `listCollectorRunsForRequester`). - Kept as a fact only: an exec wake still names the starting run in `inputProvenance.runId` (`ProcessSession.startedByRunId`), because plugins use it (#179816). It routes nothing. - The requester id fields are still written for one release, so a downgrade keeps working. No schema, stored-row or protocol change. Production delta: −227 lines in `src` (+127 / −354); whole PR −427. ## User Impact - A chat can start a background command in one turn and wait for it with `sessions_yield` in a later turn. The exit continues the chat. - A yielded subagent always continues its paused task when one of its commands exits, also after a follow-up run. - A subagent result reaches the parent chat after `/new` or compaction instead of being withheld. ## Evidence Real agent on an isolated source Gateway (`ocx src`, scratch state, port and HOME, scrubbed env), Claude Opus through the shared Claude proxy. base = merge base `96ad377596ca`, head = this PR. | Journey | base | head | |---|---|---| | J1: #200046 incident (paused child, A's exit continues the task in run 2, then B, started by run 1, exits) | parent got `child-final` (with the #200046 patch) | parent got `child-final` (patch deleted); registry `generation=4 delivery=delivered` | | J2: run 1 starts a background command; run 2 calls `sessions_yield` | `{"status":"nothing_pending"}` | `{"status":"yielded"}`; the exit wakes the chat, which replies `j2-woke` | | J3: parent spawns a child and does not yield | ordinary completion (`subagent_announce`) | ordinary completion (`subagent_announce`) | | J1 parent side: parent yields on its child | private completion (`subagent_settle`) | private completion (`subagent_settle`) | Head arms ran on the production code of `3793f6d`; later commits change only tests, docs and the failure-notice path of a required completion, which unit tests cover. A `/new` while the parent is yielded on a running child interrupts the child on both arms, so that journey does not separate them and is not a claim of this PR. Unit: `openclaw-tools.requester-yield.test.ts` now awaits a command with no starting run (fails on base). The delivery tests assert that a private completion reaches a replacement parent session. Gates: oxfmt, oxlint on changed files, `pnpm tsgo:core`, `pnpm check:test-types`, `ocx test` on `src/agents/subagents/`, requester-yield, exec background and notify suites, agents_wait, harness completion, session reactivation and adoption, `src/cron/isolated-agent`. Build, full suites and cross-OS checks: hosted CI on this head. `src/gateway/server-startup-post-attach.test.ts` fails the same way on the merge base `059db8a`; this PR does not touch it. Co-authored-by: Ayaan Zaidi <[email protected]>
…r a follow-up run (openclaw#200046) ## What Problem This Solves Fixes: a yielded subagent's final reply sometimes never reaches its requester. The child's task stays at `waiting for external continuation; delivery=pending; requester_continuation=pending` after the child wrote its answer. A paused subagent task continues under a new run id each time an exit wake resumes it (openclaw#199283). `adoptPausedSubagentRunForFollowUp` moves the task row, the completion custody and the settle batch to the new run. It did not move the background commands. Each command kept the run that started it as `originRunId`. When such a command exited after a later run had yielded, the failure was: 1. Its wake carried the retired run as `inputProvenance.runId` (`bash-tools.exec-notify.ts`, `sourceRunId: session.originRunId`). 2. `prepareReplySubagentContinuation` passes that id as `pausedRunId` (`src/auto-reply/reply/agent-runner-subagent.ts:47`). 3. `reactivateCompletedSubagentSession` returns false because the paused row now carries the newer run id (`src/gateway/session-subagent-reactivation.ts:48-52`). 4. The turn runs as a separate follow-up. The task row stays paused (`pauseReason: "sessions_yield"`), and the child's final reply is not tied to the task. Nothing announces it. The later run also could not yield on those commands: `listYieldAwaitableExecs(runId)` matches `originRunId === runId` (`bash-tools.exec-notify.ts:108-116`), so its `sessions_yield` returned `nothing_pending` or "its exit cannot resume this run", and the model started to poll. It is intermittent because it needs a command that outlives the run that started it while another wake continues the task first. A child that waits on one command at a time, or that the parent resumes with `sessions_send`, does not hit it. ## Production evidence (read-only, copied state DB) Child `land_cache_pair` (redacted to the shape): - Registry row: `runId` = the second run, `generation: 3`, `pauseReason: "sessions_yield"`, `execution.endedAt` set at the second run's yield, `delivery.status: "pending"`, `requesterSettleWake.status: "pending"`. - Transcript: the second run started a pack-smoke command and yielded. Later wakes carried the starting run ids of earlier runs (`exec` wakes named run 1 three times while run 3+ was current). Every later `sessions_yield` returned `nothing_pending` or the "cannot resume this run" error, the agent polled, and the final reply (`stopReason: stop`) went nowhere. No announce lines exist for the child. ## Why This Change Was Made - `moveRunningSessionsToRun(previousRunId, nextRunId)` in `bash-process-registry.ts`, the owner of process sessions. - `replaceSubagentRunAfterSteer` calls it when it replaces a `sessions_yield`-paused row, next to the existing settle-batch remap and controller-input retirement. Ordinary steers and completed-run follow-ups are unchanged. - Docs: `docs/concepts/subagent-yield-handoff.md`, `docs/plugins/tool-plugins.md` and the `inputProvenance` doc comment now say the wake names the run that owns the command. No new state, stored row, schema or protocol field. Production delta: +20/-2 lines in `src`, most of it comments. ## Evidence **Real agent, isolated source Gateway** (`ocx src`, scratch state/port/HOME, `env -i`), Claude Opus through the shared Claude proxy. A UI parent spawns a hidden subagent and yields. The child starts commands A (15 s) and B (50 s) and yields. A's exit continues the task in run 2, which starts C (70 s) and yields. B (started by run 1) then exits while run 2 is the paused run. base = merge base `0f25b0abd8d2`, head = this PR. | Arm | B's wake `runId` | Run 2's next `sessions_yield` | Registry row at end | Parent got the result | |---|---|---|---|---| | base | run 1 (retired) | `nothing_pending` (then polls) | `generation=2 pause=sessions_yield delivery=pending wake=pending` | **no** | | head | run 2 (current) | `yielded` | `generation=4 pause=- delivery=delivered` | **yes** (`subagent_settle`, 9 s after the child's reply) | A first base trial with C at 110 s delivered by chance: the model polled until C finished, and C's own wake (owned by run 2) continued the task. That is the same intermittency seen in production. **Unit regression** (`ocx test`, vitest from source): `subagent-registry.test.ts` › "moves the commands of the paused run to the follow-up that continues the task". It fails on base (`listYieldAwaitableExecs(followup)` is `[]`) and passes on head. **Gates**: oxfmt, oxlint on changed files, `pnpm tsgo:core`, `pnpm check:test-types`. `ocx test` on `src/agents/subagents/registry/`, `openclaw-tools.requester-yield`, `bash-tools.exec-background-followup`, `bash-process-registry`: all pass. **Full tier**: `ocx build --dts` on `d61294e737ef`, then a packed tarball: tarball integrity and the dist import graph pass. Co-authored-by: Ayaan Zaidi <[email protected]>
…openclaw#200097) ## What Problem This Solves Background commands, `sessions_yield` waits and exec-exit wakes were owned by the run that started them. A run id names one attempt, and a chat gets a new one on every turn. So every follow-up run lost the commands of the earlier runs: - A later turn could not yield on a command that an earlier turn started. `listYieldAwaitableExecs(runId)` matched `originRunId === runId`, so `sessions_yield` returned `nothing_pending` and the model started to poll. - A paused subagent task continued only when the wake named the paused run. openclaw#200046 patched one caller of this: it moved the running commands to the new run (`moveRunningSessionsToRun`). - Child completions compared the captured requester session id and lifecycle revision. After a reset or a compaction successor, a private completion was withheld with "Subagent results from the previous session were not delivered". ## Why This Change Was Made The bug class is "address work by an id that changes". The chat's session key is the only id that survives edits, resets, compaction and follow-up runs. This PR makes the key the owner: - `listYieldAwaitableExecs`, `awaitExecsForYield` and `openExecYieldResume` are keyed by the chat: agent id plus session key, so a raw shared key such as `global` stays separate per agent. A yield awaits every wake-armed command of the chat, including commands from earlier runs. - Reply admission continues the task that is paused in the chat, whichever run paused it (`continuesPausedTask` replaces `pausedRunId`). - Child and harness completions, and the failure notice of a required completion, go to the requester chat as it is now. The reads of `completionRequesterSessionId` / `LifecycleRevision`, the settle-receipt exact compare, the collector and `agents_wait` incarnation filters, and the reset replacement notice are deleted. - Deleted: `ProcessSession.originRunId`, `moveRunningSessionsToRun` (the openclaw#200046 patch), `matchesSubagentRequesterSession`, `recordRequesterReplacementNotice`, `listCollectorRunsForRequesterIncarnation` (now `listCollectorRunsForRequester`). - Kept as a fact only: an exec wake still names the starting run in `inputProvenance.runId` (`ProcessSession.startedByRunId`), because plugins use it (openclaw#179816). It routes nothing. - The requester id fields are still written for one release, so a downgrade keeps working. No schema, stored-row or protocol change. Production delta: −227 lines in `src` (+127 / −354); whole PR −427. ## User Impact - A chat can start a background command in one turn and wait for it with `sessions_yield` in a later turn. The exit continues the chat. - A yielded subagent always continues its paused task when one of its commands exits, also after a follow-up run. - A subagent result reaches the parent chat after `/new` or compaction instead of being withheld. ## Evidence Real agent on an isolated source Gateway (`ocx src`, scratch state, port and HOME, scrubbed env), Claude Opus through the shared Claude proxy. base = merge base `2baaa3c275a3`, head = this PR. | Journey | base | head | |---|---|---| | J1: openclaw#200046 incident (paused child, A's exit continues the task in run 2, then B, started by run 1, exits) | parent got `child-final` (with the openclaw#200046 patch) | parent got `child-final` (patch deleted); registry `generation=4 delivery=delivered` | | J2: run 1 starts a background command; run 2 calls `sessions_yield` | `{"status":"nothing_pending"}` | `{"status":"yielded"}`; the exit wakes the chat, which replies `j2-woke` | | J3: parent spawns a child and does not yield | ordinary completion (`subagent_announce`) | ordinary completion (`subagent_announce`) | | J1 parent side: parent yields on its child | private completion (`subagent_settle`) | private completion (`subagent_settle`) | Head arms ran on the production code of `3793f6d`; later commits change only tests, docs and the failure-notice path of a required completion, which unit tests cover. A `/new` while the parent is yielded on a running child interrupts the child on both arms, so that journey does not separate them and is not a claim of this PR. Unit: `openclaw-tools.requester-yield.test.ts` now awaits a command with no starting run (fails on base). The delivery tests assert that a private completion reaches a replacement parent session. Gates: oxfmt, oxlint on changed files, `pnpm tsgo:core`, `pnpm check:test-types`, `ocx test` on `src/agents/subagents/`, requester-yield, exec background and notify suites, agents_wait, harness completion, session reactivation and adoption, `src/cron/isolated-agent`. Build, full suites and cross-OS checks: hosted CI on this head. `src/gateway/server-startup-post-attach.test.ts` fails the same way on the merge base `113d415`; this PR does not touch it. Co-authored-by: Ayaan Zaidi <[email protected]>
) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2c) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes #206556 Fixes #206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for #206708 and for #206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 73940d3 (2 runs), 03cdb2c (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: #206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: #168227, #198204, #200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2c) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes #206556 Fixes #206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for #206708 and for #206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 73940d3 (2 runs), 03cdb2c (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: #206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: #168227, #198204, #200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]> Follow-up scan: 34d4f8f improve: list Docker streams and flag unconfirmed cleanup in Doctor (#201292); 21786f6 refactor(ui): stop sending 28 additional unused labels to translators (#207982); 9cec330 refactor(workboard): group session tiles without rescanning each column (#207380); 16a2d4b refactor(ui): lowercase log search text only once (#207383). Other hits are not required by this focused beta.2 fix. (cherry picked from commit 2a428f2) Co-authored-by: RomneyDa <[email protected]>
) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 03cdb2c) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes #206556 Fixes #206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for #206708 and for #206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 73940d3 (2 runs), 03cdb2c (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: #206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: #168227, #198204, #200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 2a428f2) Release adaptation: Suppress only hidden unbound helper events at the stable target capture; honor explicit delivery restrictions, visible sessions, active bindings, and the existing scheduled/requester custody. Companion audit: PR #206570 uses existing binding and spawn classifiers. Resume the stopped cherry-pick at the stable agent-run registry import anchor without importing main-only authority handlers. Co-authored-by: RomneyDa <[email protected]>
…claw#206570) Root cause: src/auto-reply/reply/session-event-target.ts:156 (base 7e9542f) captures `deliver` from the producing run only, so a hidden subagent's exec-wake turn keeps the requester's chat route with delivery on, and its reply is posted to that chat. Fixes openclaw#206556 Fixes openclaw#206708 Thanks @stealthybear for the report, the fix and the live repro, and @Nocha12 for openclaw#206708 and for openclaw#206709, whose active-binding exception (thread-bound subagents and persistent ACP sessions keep replying in their own conversation) this PR now carries. ## What Problem This Solves When an agent hands work to a hidden helper (a subagent) that runs a background command and waits for it, the helper's reply after the command finishes is posted straight to your chat, for example your Telegram DM with the bot. The parent agent also gets that reply and posts its own summary, so you see two messages for one result: first the helper's raw report (sometimes with notes meant only for the parent), then the summary. ## User Impact A hidden helper's wake reply now reaches only its parent agent, so you see one summary instead of two. The parent still gets the helper's result through its normal finished-task report. Visible spawned sessions keep posting to the chat as before, and thread-bound helpers and persistent ACP sessions bound to their own conversation keep replying in that thread. No setting, schema or migration. ## Why This Change Was Made The event target capture, which already decides `deliver: false` for private producers, now also sets it when the destination is a hidden subagent (`isSubagentEnvelopeSession` and not `isVisibleSpawnedSession`) with no active conversation binding (`listSessionBindingsBySessionAsync`). Without the binding check a thread-bound subagent would stop replying in its own thread. The capabilities module is loaded lazily in the async capture because a static import formed a runtime import cycle (`subagent-capabilities -> config/sessions -> ... -> session-event-target`). ## Evidence Live Telegram Test Server DM, real Gateway, Telegram delivery, spawn, exec, yield, wake and announce; only the model is scripted. The DM asks the agent to spawn a hidden helper that runs `exec` in the background, calls `sessions_yield`, and replies a marker when the exit wakes it. | Build | Helper's raw reply in the DM | Parent got the helper's result | Parent's summary in the DM | | --- | --- | --- | --- | | main 2877834 (2 runs), 7e9542f (1 run) | yes, every run | yes | yes | | this PR c428bfa (2 runs) | no | yes | yes | | `visible: true` control, main and this PR | yes (posts as before) | n/a | n/a | Thread-bound control: Telegram has no thread-bound spawn (its binding placement is `current`), so the thread case ran on Discord through QA Lab: on this head and on the earlier head without the binding check, `thread: true, mode: "session"` spawns, the child's exec wake runs and it replies. That lane's recorder cannot see SUT-created threads, so the thread message itself is covered by the unit case below, which fails without the binding check (`expected false to be undefined`) and passes with it. Observed proof lines: openclaw#206570 (comment). Local review on c428bfa: no findings. Tests: `session-event-handoff.test.ts` plus the 12 test files that import `session-event-target.ts` pass (151 tests); `check:import-cycles` reports 0 cycles. Earlier live evidence from @stealthybear (released 2026.11.10, real model on a real Telegram bot):  Related, separate: openclaw#168227, openclaw#198204, openclaw#200046. Merge danger: two-way door. A revert restores the duplicate post; nothing is stored, migrated or published. Blast radius: event turns (exec wakes, tool handoff results) of hidden subagent sessions without an active binding; ordinary, visible and bound sessions are unchanged. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes: a yielded subagent's final reply sometimes never reaches its requester. The child's task stays at
waiting for external continuation; delivery=pending; requester_continuation=pendingafter the child wrote its answer.A paused subagent task continues under a new run id each time an exit wake resumes it (#199283).
adoptPausedSubagentRunForFollowUpmoves the task row, the completion custody and the settle batch to the new run. It did not move the background commands. Each command kept the run that started it asoriginRunId.When such a command exited after a later run had yielded, the failure was:
inputProvenance.runId(bash-tools.exec-notify.ts,sourceRunId: session.originRunId).prepareReplySubagentContinuationpasses that id aspausedRunId(src/auto-reply/reply/agent-runner-subagent.ts:47).reactivateCompletedSubagentSessionreturns false because the paused row now carries the newer run id (src/gateway/session-subagent-reactivation.ts:48-52).pauseReason: "sessions_yield"), and the child's final reply is not tied to the task. Nothing announces it.The later run also could not yield on those commands:
listYieldAwaitableExecs(runId)matchesoriginRunId === runId(bash-tools.exec-notify.ts:108-116), so itssessions_yieldreturnednothing_pendingor "its exit cannot resume this run", and the model started to poll.It is intermittent because it needs a command that outlives the run that started it while another wake continues the task first. A child that waits on one command at a time, or that the parent resumes with
sessions_send, does not hit it.Production evidence (read-only, copied state DB)
Child
land_cache_pair(redacted to the shape):runId= the second run,generation: 3,pauseReason: "sessions_yield",execution.endedAtset at the second run's yield,delivery.status: "pending",requesterSettleWake.status: "pending".execwakes named run 1 three times while run 3+ was current). Every latersessions_yieldreturnednothing_pendingor the "cannot resume this run" error, the agent polled, and the final reply (stopReason: stop) went nowhere. No announce lines exist for the child.Why This Change Was Made
moveRunningSessionsToRun(previousRunId, nextRunId)inbash-process-registry.ts, the owner of process sessions.replaceSubagentRunAfterSteercalls it when it replaces asessions_yield-paused row, next to the existing settle-batch remap and controller-input retirement. Ordinary steers and completed-run follow-ups are unchanged.docs/concepts/subagent-yield-handoff.md,docs/plugins/tool-plugins.mdand theinputProvenancedoc comment now say the wake names the run that owns the command.No new state, stored row, schema or protocol field. Production delta: +20/-2 lines in
src, most of it comments.Evidence
Real agent, isolated source Gateway (
ocx src, scratch state/port/HOME,env -i), Claude Opus through the shared Claude proxy. A UI parent spawns a hidden subagent and yields. The child starts commands A (15 s) and B (50 s) and yields. A's exit continues the task in run 2, which starts C (70 s) and yields. B (started by run 1) then exits while run 2 is the paused run. base = merge basebef242d04174, head = this PR.runIdsessions_yieldnothing_pending(then polls)generation=2 pause=sessions_yield delivery=pending wake=pendingyieldedgeneration=4 pause=- delivery=deliveredsubagent_settle, 9 s after the child's reply)A first base trial with C at 110 s delivered by chance: the model polled until C finished, and C's own wake (owned by run 2) continued the task. That is the same intermittency seen in production.
Unit regression (
ocx test, vitest from source):subagent-registry.test.ts› "moves the commands of the paused run to the follow-up that continues the task". It fails on base (listYieldAwaitableExecs(followup)is[]) and passes on head.Gates: oxfmt, oxlint on changed files,
pnpm tsgo:core,pnpm check:test-types.ocx testonsrc/agents/subagents/registry/,openclaw-tools.requester-yield,bash-tools.exec-background-followup,bash-process-registry: all pass.Full tier:
ocx build --dtsond61294e737ef, then a packed tarball: tarball integrity and the dist import graph pass.