Repository navigation
fix(subagents): wake the parent when a follow-up finishes a yielded child - #120187
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 9:40 AM ET / 13:40 UTC. ClawSweeper reviewWhat this changesThe PR makes a default-delivery plugin follow-up reuse a self-yielded subagent run so its completion reaches the original waiting requester. Merge readinessKeep open: current main still registers this follow-up as a separate subagent row, while the PR moves ownership at gateway admission before execution. No actionable patch defect was found; likely related person: steipete (medium confidence, recent durability and review-cycle owner). Priority: P1 Review scores
Verification
How this fits togetherPlugin runtime follow-ups enter through the Gateway and are tracked as subagent registry rows. The registry persists requester ownership and completion state, then delivers the finished child result to the waiting parent. flowchart LR
A[Plugin follow-up] --> B[Gateway admission]
B --> C{Paused default-delivery run?}
C -->|Yes| D[Persist ownership transfer]
C -->|No| E[Register separate run]
D --> F[Subagent execution]
E --> F
F --> G[Completion delivery]
G --> H[Original requester]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +420, Tests +284, Docs +21, Other +1. Total +726 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Land the admission-time ownership transfer with its persistence rollback and boundary coverage, while retaining explicit-requester follow-ups as independent runs. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: current main's admission path unconditionally registers a new plugin subagent row, and the supplied exact-head Gateway scenario exercises the corrected sequence. Is this the best way to solve the issue? Yes—the best fix is to transfer the paused registry owner at admission, before provider execution, rather than attempt downstream delivery recovery after requester ownership was lost. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 295c8dfe6eb7. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
2457ba5 to
eddfe3b
Compare
|
@clawsweeper re-review Exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
eddfe3b to
9f131d8
Compare
…hild A sub-agent that calls sessions_yield on its own behalf parks its run and correctly withholds the parent's announce. But a later follow-up to that same child session registered a sibling registry row instead of continuing the paused one, so the requester defaulted to the child's own main session and the original parent — itself idle behind sessions_yield — was never woken. The paused row also stayed an unsettled descendant, deferring the parent's settle batch forever with nothing recorded explaining the silence. Follow-up dispatch now adopts the paused row through the existing post-steer replacement seam, inheriting the requester identity and carrying the settle-wake credential forward with its frozen batch membership remapped to the new run id. A follow-up that names its own requester keeps registering separately, since an explicit requester is a delivery opt-in that adoption would silently drop. Also stops frozen-result refill from targeting paused rows: a yield clears the result on purpose, so refilling from the session would attribute a later turn's text to the paused run. Closes openclaw#120157
Adoption looked up the newest run for the child session and adopted it only when that row was itself paused. A requester-bound follow-up deliberately stays a sibling, but it registers at a higher generation and becomes that newest row, so any later default follow-up saw an unpaused newest row, declined adoption, and registered yet another sibling. The original requester stayed parked behind a paused row that can never announce -- the same silent stall this fix exists to remove, reached through a valid mixed-delivery sequence. The latest-run query now takes an optional predicate applied before the generation comparison, so a caller that owns a specific row class selects the newest row of that class. Adoption asks for the newest `sessions_yield` row directly instead of inferring it from generation order. Docs now state that continuation applies to default delivery, since a follow-up carrying its own requester runs as a sibling by design.
…ndary The unit and gateway-method tests for paused-run adoption assert on registry rows, which proves the bookkeeping but not that an operator ever sees the result. This adds the boundary proof: a real gateway child, the QA mock channel, and the mock provider driving a subagent that pauses itself and finishes only on a later follow-up. A fixture plugin owns both legs. Its `before_dispatch` hook spawns the child with `completionDelivery: "current-requester"`, so the announce has the operator turn as its audience. An HTTP route then dispatches the follow-up to that same paused session using default delivery -- the path adoption is meant to catch. A requester-bound follow-up would opt into its own audience and run as a sibling instead, so the two legs must differ here. The mock provider gains a child that yields on its own behalf. Both of its turns match on the current prompt rather than the shared transcript, so the yielded kickoff cannot make the follow-up turn yield a second time. The scenario asserts both sides of the invariant: no outbound traffic while the child is paused, and exactly one announce carrying the follow-up marker once it ends. Reverting the adoption call site fails this test in the way that matters: the child still produces its marker and the run still ends with stopReason=stop, but nothing reaches the requester and the wait times out. The result is computed and then silently dropped -- which is the failure this repair exists to remove.
The all-exports pass listed one fixture entry by name, so every new QA Lab fixture plugin lands as an unused file and turns check-dependencies red until someone remembers this file. Nothing imports these entries by design: the Gateway E2E loads them through plugin config paths.
Adoption is gated on plugin_subagent task tracking, which only createGatewaySubagentRuntime().run sets, so api.runtime.subagent.run is the sole route into it. Writing that as one example implied other follow-up paths to a paused session continue the run too; they are not tracked as sub-agent runs and announce nobody.
Fail plugin follow-up admission closed when the paused-run ownership swap cannot be persisted, while retaining the existing restart-recovery return-false contract. Trim duplicate tests and keep boundary coverage for requester routing, wake-batch remapping, repeated yield, and persistence rollback. Co-authored-by: zhou.huanfeng <[email protected]>
9f131d8 to
15f2400
Compare
|
@clawsweeper re-review Exact rebased head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
Co-authored-by: zhou.huanfeng <[email protected]>
|
@clawsweeper re-review Exact head |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
…hild (openclaw#120187) * fix(subagents): wake the parent when a follow-up finishes a yielded child A sub-agent that calls sessions_yield on its own behalf parks its run and correctly withholds the parent's announce. But a later follow-up to that same child session registered a sibling registry row instead of continuing the paused one, so the requester defaulted to the child's own main session and the original parent — itself idle behind sessions_yield — was never woken. The paused row also stayed an unsettled descendant, deferring the parent's settle batch forever with nothing recorded explaining the silence. Follow-up dispatch now adopts the paused row through the existing post-steer replacement seam, inheriting the requester identity and carrying the settle-wake credential forward with its frozen batch membership remapped to the new run id. A follow-up that names its own requester keeps registering separately, since an explicit requester is a delivery opt-in that adoption would silently drop. Also stops frozen-result refill from targeting paused rows: a yield clears the result on purpose, so refilling from the session would attribute a later turn's text to the paused run. Closes openclaw#120157 * fix(subagents): select the paused owner past a requester-bound sibling Adoption looked up the newest run for the child session and adopted it only when that row was itself paused. A requester-bound follow-up deliberately stays a sibling, but it registers at a higher generation and becomes that newest row, so any later default follow-up saw an unpaused newest row, declined adoption, and registered yet another sibling. The original requester stayed parked behind a paused row that can never announce -- the same silent stall this fix exists to remove, reached through a valid mixed-delivery sequence. The latest-run query now takes an optional predicate applied before the generation comparison, so a caller that owns a specific row class selects the newest row of that class. Adoption asks for the newest `sessions_yield` row directly instead of inferring it from generation order. Docs now state that continuation applies to default delivery, since a follow-up carrying its own requester runs as a sibling by design. * test(qa): prove post-yield follow-up delivery through the gateway boundary The unit and gateway-method tests for paused-run adoption assert on registry rows, which proves the bookkeeping but not that an operator ever sees the result. This adds the boundary proof: a real gateway child, the QA mock channel, and the mock provider driving a subagent that pauses itself and finishes only on a later follow-up. A fixture plugin owns both legs. Its `before_dispatch` hook spawns the child with `completionDelivery: "current-requester"`, so the announce has the operator turn as its audience. An HTTP route then dispatches the follow-up to that same paused session using default delivery -- the path adoption is meant to catch. A requester-bound follow-up would opt into its own audience and run as a sibling instead, so the two legs must differ here. The mock provider gains a child that yields on its own behalf. Both of its turns match on the current prompt rather than the shared transcript, so the yielded kickoff cannot make the follow-up turn yield a second time. The scenario asserts both sides of the invariant: no outbound traffic while the child is paused, and exactly one announce carrying the follow-up marker once it ends. Reverting the adoption call site fails this test in the way that matters: the child still produces its marker and the run still ends with stopReason=stop, but nothing reaches the requester and the wait times out. The result is computed and then silently dropped -- which is the failure this repair exists to remove. * fix(ci): match QA Lab fixture plugin entries as a group in knip The all-exports pass listed one fixture entry by name, so every new QA Lab fixture plugin lands as an unused file and turns check-dependencies red until someone remembers this file. Nothing imports these entries by design: the Gateway E2E loads them through plugin config paths. * docs(subagents): scope yield continuation to plugin runtime follow-ups Adoption is gated on plugin_subagent task tracking, which only createGatewaySubagentRuntime().run sets, so api.runtime.subagent.run is the sole route into it. Writing that as one example implied other follow-up paths to a paused session continue the run too; they are not tracked as sub-agent runs and announce nobody. * fix(subagents): reject undurable paused-run adoption Fail plugin follow-up admission closed when the paused-run ownership swap cannot be persisted, while retaining the existing restart-recovery return-false contract. Trim duplicate tests and keep boundary coverage for requester routing, wake-batch remapping, repeated yield, and persistence rollback. Co-authored-by: zhou.huanfeng <[email protected]> * docs(subagents): clarify yielded-run steering Co-authored-by: zhou.huanfeng <[email protected]> --------- Co-authored-by: Peter Steinberger <[email protected]>
Closes #120157
What Problem This Solves
A parent can spawn a sub-agent and yield while it waits for completion. If the child also calls
sessions_yield, a plugin may later continue the child by callingapi.runtime.subagent.runwith the samesessionKeyand default delivery.Before this change, gateway admission always registered that follow-up as a new row. Without an explicit requester, the new row belonged to the child agent's main session rather than the original parent. Execution-time reactivation then read the newer running row and returned without adopting the paused owner. The follow-up result was therefore lost or attributed to the wrong requester. The registry sweeper can later revisit the original settle-wake state, but it cannot reconstruct the follow-up result that was recorded on the sibling row, so it is not a prompt result-bearing wake.
Why This Change Was Made
Default-delivery plugin follow-ups now adopt the newest
sessions_yield-paused owner for the child session before provider execution begins. The transition:requesterSettleWakeforward and remaps its frozenbatchRunIdsfrom the retired run ID to the follow-up run ID;The related frozen-result refill path now skips paused rows. A yield deliberately clears that row's result, so text produced by a later turn must not be refrozen as the paused run's completion.
No plugin SDK, gateway protocol, config, or schema surface changes.
User Impact
Plugins can use a yielded sub-agent as a durable waiter for external work. A default-delivery
api.runtime.subagent.runfollow-up on the paused session continues the original unit of work and delivers its final result to the waiting requester. A follow-up that yields again remains paused. A follow-up with an explicit requester still runs independently and delivers to that requester.Evidence
Exact-head mock-gateway behavior
Verified on
99496dd6826443d8076d71ba77e8f6e69441d6e2, with local HEAD equal to the live PR head:The test uses a mock channel API, mock OpenAI provider, and a real ephemeral gateway child. It observes no outbound message during the child's 15-second paused window, dispatches the default-delivery plugin follow-up through an authenticated gateway route, and observes exactly one result marker in the original requester conversation.
{ "schemaVersion": 1, "status": "passed", "head": "99496dd6826443d8076d71ba77e8f6e69441d6e2", "source": "local-exact-head-fallback", "harness": "qa-channel+mock-openai+ephemeral-child", "deliverySeamStubbed": false, "checks": { "spawnAcknowledged": true, "pausedQuietWindowMs": 15000, "pausedOutboundCount": 0, "followUpHttpStatus": 200, "followUpDelivery": "default", "distinctGatewayRunId": true, "originalRequesterMarkerDelivered": true, "markerDeliveryCount": 1 }, "counts": { "passed": 1, "failed": 0 } }The local fallback was required because the Blacksmith Testbox launcher was not installed on this host and the configured managed Crabbox broker returned 401 before allocation. Neither attempt created a lease or ran repository code.
Focused regression suites
Coverage retains the owner-boundary cases that pay rent: wake/batch remapping, a follow-up that yields again, explicit-requester separation, adoption past a newer requester-bound sibling, frozen-result refill exclusion, and persistence-failure rollback before provider start. Two duplicate/trivial cases were removed during maintainer review.
Static and review evidence
git diff --check: passed.[email protected]for untouchedpackages/terminal-core, while that workspace requires and the canonical checkout contains[email protected]. Exact-head CI remains the typecheck gate.origin/main: clean, no accepted/actionable findings.LOC delta
+135 / -8(net+127)+582 / -5+21 / -0+5 / -4+743 / -17The positive production delta establishes the missing registry ownership and durability boundary. It avoids reconstructing requester identity downstream after admission has already lost it.