Repository navigation
fix(agents): sessions_yield awaits wake-armed background commands in one-shot runs - #199283
Conversation
|
🦞👀 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 lets sessions_yield await background commands and resume hidden subagents or isolated cron runs with their exit results. Example: A hidden subagent starts a CI waiter with timeoutSeconds: 1500 that exits after 240 seconds.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR provides useful bounded waiting for one-shot runs, resolves the earlier callable-tool finding, and introduces no actionable defect found in this review; required CI remains blocked by an inherited Activity test failure. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe exec notification owner converts process exits into continuation input, while requester-yield admission, subagent task adoption, and the cron executor preserve the originating work's completion ownership. flowchart TD
A[Agent starts background command] --> B[Exec captures callable continuation]
B --> C[sessions_yield awaits command]
C --> D[Command exits]
D --> E[Subagent task resumes]
D --> F[Cron operation resumes]
E --> G[Final result delivered]
F --> G
Technical reviewBest possible solution: Use the existing exec, yield, task-adoption, and cron owners to resume bounded command waits while preserving manual collection wherever yield is unavailable. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the missing one-shot continuation capability, and the supplied base/fix Gateway traces demonstrate its polling consequence; this read-only review executed no target code. Is this the best way to solve the issue? The change extends the existing completion owners without a new tool or setting, and its small runtime resume slot handles the distinct cron lifetime rather than creating a competing scheduler. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against d3438ec2b2ef. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +173, Tests +98, Docs +15. Total +286 across 28 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: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 14, 2026, 7:47 PM ET / November 15, 2026, 00:47 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
…one-shot runs Hidden subagents and isolated cron runs end with their final reply, so a background command's exit could not resume them and they polled instead. sessions_yield now also awaits the wake-armed commands the current run started (bounded by each command's deadline). The exit resumes a yielded hidden subagent through an ordinary exec wake turn that continues its paused task, and resumes a yielded cron run in place with the same wake content. Co-authored-by: obviyus <[email protected]>
… callable Collectors and tool policies can remove sessions_yield while keeping exec and process. Their one-shot commands keep manual-collection guidance, read from the run's final callable tool set like process availability. Co-authored-by: obviyus <[email protected]>
d51e737 to
cace873
Compare
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer override for exact head cace873 (ClawSweeper
All other required jobs are green on this head. |
|
Landed as 1fff14f. Hidden subagents and cron agent turns can now call sessions_yield on a wake-armed background command; its exit resumes the run with the result. Real-agent E2E (Claude Opus): process polls 76 -> 0 (subagent), 61 -> 0 (cron), 12 -> 0 (dashboard). |
…one-shot runs (openclaw#199283) ## What Problem This Solves Fixes: one-shot runs cannot wait for a background command without polling. A hidden subagent or an isolated cron agent turn ends with its final reply, so "end the turn and let the exit wake you" does not work there: - A hidden subagent gets the exit only as a passive system event in its next turn, which never comes. Its running result therefore says "Automatic completion wake is unavailable … use poll with a timeout", and the agent calls `process poll` every 10–30 s for the whole wait. - An isolated cron run gets the same manual-collection guidance. When the run ends first, a queued exit still arrives later as an extra follow-up turn, which answers `NO_REPLY`. - `sessions_yield` only awaited child sessions. With a running command and no child, it said "No pending child completion … did not pause the turn". In a hidden subagent it refused outright ("Use process to poll and collect it before yielding"). ## User Impact User impact: a subagent or automation that waits for CI, a deploy or any long command starts one background command and calls `sessions_yield`. The command's exit resumes the same run with the exit result, and the run reports normally. No poll loop, fewer model round trips and tokens, and no spurious `NO_REPLY` turns after a cron run. Ordinary chat sessions are unchanged: their exit still wakes the conversation when the turn ends. ## Why This Change Was Made **Owners extended (no new tool, parameter, state or stored row):** - **Exec wake target capture** (`prepareExecExitNotification`): hidden subagent and cron-run commands now capture their own session as the wake target and record `exitWakeAfterYield`, but only when `sessions_yield` is callable in that run. The exec tool reads this from the run's final callable tool set, the same way it reads `process` availability. Collectors (which never get `sessions_yield`) and tool policies that remove it keep the previous manual-collection guidance. `hasExitWake` stays the single fact that the running result, idle `process poll` text and the Control UI waiting card read. For a one-shot run it also requires a deadline, so a wait is always bounded by the command's `timeoutSeconds`. A timeout already ends the command, and that exit resumes the run. `timeoutSeconds: 0` keeps manual-collection guidance. - **Running result text** (`describeExitWake`): one-shot runs read "This run resumes with its result when it exits, silent success included, if you call sessions_yield. If only waiting remains, call sessions_yield now; do not poll it or start another command for the same result." Ordinary sessions keep the step 2 text. - **Yield claim** (`createRequesterYieldCallback`): a wake-armed running command that the current run started (`originRunId`) is a completion claim, like a pending child. An accepted yield marks those commands (`resumesYieldedRun`). The step 2 refusal of a hidden-subagent yield with uncollected background work stays for commands whose exit cannot resume the run. - **Hidden subagent resume** (`maybeNotifyOnExit` + `prepareReplySubagentContinuation`): the exit of an awaited command is sent as the ordinary exec wake turn (same content as step 2: exit code, duration, 2,000-char tail) instead of a passive event. It carries the starting run as `sourceRunId`. Reply admission treats an `exec` wake exactly like a tool handoff result: it continues the paused task only when that run is the yielded one, so the subagent's final reply still goes to its requester through the registry. A hidden subagent that did not yield still gets only the passive notice. - **Cron run resume** (`executeCronRun`): the cron executor opens a per-run resume slot. A yield on the run's own commands returns `{ resumesInPlace: true }`; the embedded runner ends the turn but keeps the reply operation open, and the executor runs the next turn in the same operation with the exit text as the prompt. The resumed turn's reply is the run's result. A cron yield for children keeps the existing scheduler-owned behavior. A requested Stop or kill releases the wait without a turn. - **Text and docs**: `sessions_yield` and exec descriptions, the cron unattended preamble (the "will not resume after `sessions_yield`" sentence now applies only to child yields), `docs/tools/exec.md`, `docs/gateway/background-process.md`, `docs/tools/subagents/tool-reference.md`, `docs/concepts/subagent-yield-handoff.md`. Prompt snapshots regenerated. **Accepted edge cases** (named, no code): a command that exits in the instant between an accepted subagent yield and the pause being published runs as a separate follow-up turn instead of continuing the paused task (same window as the existing tool-handoff resume). The Control UI waiting card in a hidden subagent session now shows for wake-armed commands, because the exit can resume the run. An interactive session that calls `sessions_yield` on a wake-armed command gets `yielded`, which ends the turn exactly as ending it normally would. Production delta: +199/−49 lines in `src` (excluding tests). ## Evidence **Real agent, isolated source Gateway** (`ocx src`, pinned Bun fork, own state/port/HOME, `env -i`). Claude Opus through the shared Claude proxy, OpenClaw runtime, direct tool surface, `automations` denied. A fake CI flips to passed 240 s after the first status check. Fresh session per trial, 6 trials per arm, measured from the Gateway's own transcript store. base = `8ae26d8ad99d` (`main` at branch time), fix = `bfd56dc84d66` (first head). The second head (`d51e737ba7da`, manual collection kept where `sessions_yield` is not callable) reran 3 hidden-subagent and 3 cron trials: 6/6 delivered, **0** polls, 5/5 background waiters resumed by their exit (1 cron trial waited in turn). | Scenario | Arm | Final result delivered | `process poll` calls | Exit resumed the run | Spurious `NO_REPLY` turns | Tokens / trial | |---|---|---|---|---|---|---| | (a) parent spawns a hidden subagent that waits for CI, parent reports | base | 6/6 | **76** (all in the subagent) | 0/6 | 0 | 594k | | | fix | 6/6 | **0** | 5/5 waiters (1 trial waited in turn) | 0 | 314k | | (b) isolated cron agent turn waits for CI | base | 6/6 | **61** (12 idle) | 0/6 (2 exits arrived after the run) | **3** | 477k | | | fix | 6/6 | **0** | 5/5 waiters (1 trial waited in turn) | 0 | 156k | | (c) ordinary dashboard session, S2 (`ci-status`) | base | 6/6 | 12 | 6/6 | 0 | 296k | | | fix | 6/6 | **0** | 6/6 | 0 | 198k | (a) parent: in every fix trial the parent yielded for the child and received the child's final summary through the existing subagent completion; in 5/6 the child's reply came from the exec-resumed turn. (b) base: the run polled until CI passed, answered, and the queued exit then started an extra follow-up turn in 3 trials. (c): the ordinary session's running-result text is unchanged. Claude calls `sessions_yield` after starting the waiter in 4/6 trials on base and 4/6 on this head. On base that returns `nothing_pending` and the agent then polls in 3 of those trials (12 polls); here the yield is accepted, the turn ends and the exit wakes the conversation. Two fix trials ran in a supplemental 2-trial arm, because a concurrent packaging step briefly rewrote `package.json` and broke two trial sends in the first arm. Redacted trace, hidden subagent, fix (P = parent, S = subagent): ```text P +13s sessions_spawn → accepted P +17s sessions_yield → {"status":"yielded"} S +22s exec {"yieldMs":120000,"timeoutSeconds":1500} 'cd pr-1 && …loop until ci-status passes…' S +142s -> Command still running (session delta-sage:…, pid …), times out in 23m. This run resumes with its result when it exits, silent success included, if you call sessions_yield. If only waiting remains, call sessions_yield now; do not poll it … S +145s sessions_yield → {"status":"yielded"} S +263s USER: Exec completed (delta-sa, code 0, 4m1s): … PR openclaw#4241: all 15 checks passed. Summary: build-1-… green S +266s write pr-1/RESULT.md S +269s reply: All 15 CI checks on PR openclaw#4241 have passed. … PR openclaw#4241: all 15 checks passed. Summary: build-1-… green P +270s USER: [Subagent Context] Every subagent in this batch has now settled … P +279s reply: The subagent says CI on PR openclaw#4241 passed. Its summary line is: PR openclaw#4241: all 15 checks passed … ``` Same scenario, base: the subagent's running result says "Automatic completion wake is unavailable after ending this turn … use poll with a timeout", then 14 `process poll timeout=30000` calls each return `PR openclaw#4241: 4 checks pending, 11 passed … Process still running.` until it exits. Cron, fix: `exec` → running result with the `sessions_yield` text → `sessions_yield` → `{"status":"yielded"}` → `Exec completed (tender-c, code 0, 4m1s): …` as the next turn of the same run → `ci-status > RESULT.md` → final reply `PR openclaw#4241: all 15 checks passed …`, recorded as the run summary. **Tests** (`vitest` from source): - `bash-tools.exec-background-followup.test.ts`: a hidden subagent's command resumes it only after `sessions_yield` awaits it (passive notice otherwise; wake turn with `source: "exec"`, `sourceRunId` and the step 2 content when yielded); a yielded cron run resumes in place with the exit text and sends no session event; cron running results carry the `sessions_yield` text. - `bash-tools.exec-background-followup.test.ts` also keeps the `main` behavior where `sessions_yield` is not callable: a hidden subagent gets manual-collection guidance and no wake promise, and a cron run is told to collect before ending the turn. - `openclaw-tools.requester-yield.test.ts`: a wake-armed command the run started is a yield claim only when it has a deadline; only an accepted yield arms the resume. - The two new tests fail on `main`, where the resume path does not exist; the updated cron assertions also fail there. The exec/process, descriptions, `sessions_yield` tool, requester yield, embedded runner yield orchestration, cron run lifecycle, model-switch retry and prompt-snapshot suites pass. `tsgo:core` passes. **Full tier**: `ocx build --dts` on the rebased head (`cace873cdf6c`), then a packed tarball install: tarball integrity, `openclaw --version` (`2026.11.3 (cace873)`) and `gateway --help` pass; the packed `bash-tools.exec-output` chunk carries the new guidance. **Limits:** - Claude only, direct tool surface; OpenAI and Code Mode were not measured for this step. - In one trial per fix arm (a) and (b), the agent waited in turn with a capped `yieldMs` block instead of backgrounding; it made no polls. - The cron harness has no chat channel, so every run (base and fix) records `completionStatus: failed` for delivery; the run summary is the agent's final reply in both arms. - Gateway restart mid-wait is out of scope (step 5). **CI:** rebased onto `main` `d0193c2d8434` (picks up openclaw#199113, which only changed the exec-completion enqueue import; no conflict in the yield/wake path). Focused yield, exec, cron and embedded-runner suites and `tsgo:core` pass on the rebased head. If `checks-ui-e2e (1/2)` fails in `ui/src/e2e/chat-cli-history-redaction.e2e.test.ts` ("preserves tool source in Activity while bounding the visible preview", waiting for `.activity-empty`), that failure is on `main`: openclaw#199168 removed the Activity element, but this test still waits for it. Locally, `pnpm test:ui:e2e ui/src/e2e/chat-cli-history-redaction.e2e.test.ts` fails the same way on `main` `d0193c2d8434` and on this head (1 failed, 1 passed in both). This PR touches no `ui/` file. Other PRs pass that shard because their changed files select only 6 UI test files that do not include this one; this PR's change set selects 19. Co-authored-by: Ayaan Zaidi <[email protected]>
…r a follow-up run (#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 (#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 `bef242d04174`, 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]>
…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]>
What Problem This Solves
Fixes: one-shot runs cannot wait for a background command without polling. A hidden subagent or an isolated cron agent turn ends with its final reply, so "end the turn and let the exit wake you" does not work there:
process pollevery 10–30 s for the whole wait.NO_REPLY.sessions_yieldonly awaited child sessions. With a running command and no child, it said "No pending child completion … did not pause the turn". In a hidden subagent it refused outright ("Use process to poll and collect it before yielding").User Impact
User impact: a subagent or automation that waits for CI, a deploy or any long command starts one background command and calls
sessions_yield. The command's exit resumes the same run with the exit result, and the run reports normally. No poll loop, fewer model round trips and tokens, and no spuriousNO_REPLYturns after a cron run. Ordinary chat sessions are unchanged: their exit still wakes the conversation when the turn ends.Why This Change Was Made
Owners extended (no new tool, parameter, state or stored row):
prepareExecExitNotification): hidden subagent and cron-run commands now capture their own session as the wake target and recordexitWakeAfterYield, but only whensessions_yieldis callable in that run. The exec tool reads this from the run's final callable tool set, the same way it readsprocessavailability. Collectors (which never getsessions_yield) and tool policies that remove it keep the previous manual-collection guidance.hasExitWakestays the single fact that the running result, idleprocess polltext and the Control UI waiting card read. For a one-shot run it also requires a deadline, so a wait is always bounded by the command'stimeoutSeconds. A timeout already ends the command, and that exit resumes the run.timeoutSeconds: 0keeps manual-collection guidance.describeExitWake): one-shot runs read "This run resumes with its result when it exits, silent success included, if you call sessions_yield. If only waiting remains, call sessions_yield now; do not poll it or start another command for the same result." Ordinary sessions keep the step 2 text.createRequesterYieldCallback): a wake-armed running command that the current run started (originRunId) is a completion claim, like a pending child. An accepted yield marks those commands (resumesYieldedRun). The step 2 refusal of a hidden-subagent yield with uncollected background work stays for commands whose exit cannot resume the run.maybeNotifyOnExit+prepareReplySubagentContinuation): the exit of an awaited command is sent as the ordinary exec wake turn (same content as step 2: exit code, duration, 2,000-char tail) instead of a passive event. It carries the starting run assourceRunId. Reply admission treats anexecwake exactly like a tool handoff result: it continues the paused task only when that run is the yielded one, so the subagent's final reply still goes to its requester through the registry. A hidden subagent that did not yield still gets only the passive notice.executeCronRun): the cron executor opens a per-run resume slot. A yield on the run's own commands returns{ resumesInPlace: true }; the embedded runner ends the turn but keeps the reply operation open, and the executor runs the next turn in the same operation with the exit text as the prompt. The resumed turn's reply is the run's result. A cron yield for children keeps the existing scheduler-owned behavior. A requested Stop or kill releases the wait without a turn.sessions_yieldand exec descriptions, the cron unattended preamble (the "will not resume aftersessions_yield" sentence now applies only to child yields),docs/tools/exec.md,docs/gateway/background-process.md,docs/tools/subagents/tool-reference.md,docs/concepts/subagent-yield-handoff.md. Prompt snapshots regenerated.Accepted edge cases (named, no code): a command that exits in the instant between an accepted subagent yield and the pause being published runs as a separate follow-up turn instead of continuing the paused task (same window as the existing tool-handoff resume). The Control UI waiting card in a hidden subagent session now shows for wake-armed commands, because the exit can resume the run. An interactive session that calls
sessions_yieldon a wake-armed command getsyielded, which ends the turn exactly as ending it normally would.Production delta: +199/−49 lines in
src(excluding tests).Evidence
Real agent, isolated source Gateway (
ocx src, pinned Bun fork, own state/port/HOME,env -i). Claude Opus through the shared Claude proxy, OpenClaw runtime, direct tool surface,automationsdenied. A fake CI flips to passed 240 s after the first status check. Fresh session per trial, 6 trials per arm, measured from the Gateway's own transcript store. base =10159aefda9c(mainat branch time), fix =bfd56dc84d66(first head). The second head (d51e737ba7da, manual collection kept wheresessions_yieldis not callable) reran 3 hidden-subagent and 3 cron trials: 6/6 delivered, 0 polls, 5/5 background waiters resumed by their exit (1 cron trial waited in turn).process pollcallsNO_REPLYturnsci-status)(a) parent: in every fix trial the parent yielded for the child and received the child's final summary through the existing subagent completion; in 5/6 the child's reply came from the exec-resumed turn. (b) base: the run polled until CI passed, answered, and the queued exit then started an extra follow-up turn in 3 trials. (c): the ordinary session's running-result text is unchanged. Claude calls
sessions_yieldafter starting the waiter in 4/6 trials on base and 4/6 on this head. On base that returnsnothing_pendingand the agent then polls in 3 of those trials (12 polls); here the yield is accepted, the turn ends and the exit wakes the conversation. Two fix trials ran in a supplemental 2-trial arm, because a concurrent packaging step briefly rewrotepackage.jsonand broke two trial sends in the first arm.Redacted trace, hidden subagent, fix (P = parent, S = subagent):
Same scenario, base: the subagent's running result says "Automatic completion wake is unavailable after ending this turn … use poll with a timeout", then 14
process poll timeout=30000calls each returnPR #4241: 4 checks pending, 11 passed … Process still running.until it exits.Cron, fix:
exec→ running result with thesessions_yieldtext →sessions_yield→{"status":"yielded"}→Exec completed (tender-c, code 0, 4m1s): …as the next turn of the same run →ci-status > RESULT.md→ final replyPR #4241: all 15 checks passed …, recorded as the run summary.Tests (
vitestfrom source):bash-tools.exec-background-followup.test.ts: a hidden subagent's command resumes it only aftersessions_yieldawaits it (passive notice otherwise; wake turn withsource: "exec",sourceRunIdand the step 2 content when yielded); a yielded cron run resumes in place with the exit text and sends no session event; cron running results carry thesessions_yieldtext.bash-tools.exec-background-followup.test.tsalso keeps themainbehavior wheresessions_yieldis not callable: a hidden subagent gets manual-collection guidance and no wake promise, and a cron run is told to collect before ending the turn.openclaw-tools.requester-yield.test.ts: a wake-armed command the run started is a yield claim only when it has a deadline; only an accepted yield arms the resume.main, where the resume path does not exist; the updated cron assertions also fail there. The exec/process, descriptions,sessions_yieldtool, requester yield, embedded runner yield orchestration, cron run lifecycle, model-switch retry and prompt-snapshot suites pass.tsgo:corepasses.Full tier:
ocx build --dtson the rebased head (cace873cdf6c), then a packed tarball install: tarball integrity,openclaw --version(2026.11.3 (cace873)) andgateway --helppass; the packedbash-tools.exec-outputchunk carries the new guidance.Limits:
yieldMsblock instead of backgrounding; it made no polls.completionStatus: failedfor delivery; the run summary is the agent's final reply in both arms.CI: rebased onto
main92016ce978f0(picks up #199113, which only changed the exec-completion enqueue import; no conflict in the yield/wake path). Focused yield, exec, cron and embedded-runner suites andtsgo:corepass on the rebased head. Ifchecks-ui-e2e (1/2)fails inui/src/e2e/chat-cli-history-redaction.e2e.test.ts("preserves tool source in Activity while bounding the visible preview", waiting for.activity-empty), that failure is onmain: #199168 removed the Activity element, but this test still waits for it. Locally,pnpm test:ui:e2e ui/src/e2e/chat-cli-history-redaction.e2e.test.tsfails the same way onmain92016ce978f0and on this head (1 failed, 1 passed in both). This PR touches noui/file. Other PRs pass that shard because their changed files select only 6 UI test files that do not include this one; this PR's change set selects 19.