Skip to content

fix(subagents): wake the parent when a follow-up finishes a yielded child - #120187

Merged
steipete merged 7 commits into
openclaw:mainfrom
wonfong:fix/subagent-yield-followup-adoption
Aug 8, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
wonfong:fix/subagent-yield-followup-adoption

Conversation

@wonfong

@wonfong wonfong commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

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 calling api.runtime.subagent.run with the same sessionKey and 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:

  • preserves the original requester and completion-delivery contract;
  • carries requesterSettleWake forward and remaps its frozen batchRunIds from the retired run ID to the follow-up run ID;
  • retains the follow-up task text for restart recovery;
  • fails gateway admission closed if the owner swap cannot be persisted, restoring the paused source row instead of starting untracked work or registering a sibling; and
  • leaves explicit-requester follow-ups as separate siblings, because those calls intentionally choose their own delivery audience.

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.run follow-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:

OPENCLAW_E2E_VERBOSE=1 node scripts/run-vitest.mjs run \
  --config test/vitest/vitest.e2e.config.ts \
  extensions/qa-lab/src/plugin-subagent-self-yield-followup.e2e.test.ts

Test Files  1 passed (1)
     Tests  1 passed (1)
  Duration  67.70s (tests 55.03s)

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

node scripts/run-vitest.mjs \
  src/agents/subagent-registry.test.ts \
  src/agents/subagent-registry-lifecycle.test.ts \
  src/agents/subagent-registry-restart-recovery.test.ts \
  src/agents/subagent-control.test.ts \
  src/gateway/server-methods/agent.test.ts

Gateway:                  272 passed
Agents core:              333 passed
Agents core isolated:      29 passed
Total:                    634 passed

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.
  • Targeted changed gate: conflict markers, env-var and max-lines ratchets, formatting, dependency pins, Plugin SDK boundaries, package patches, and dead-export scans passed.
  • Local fallback typecheck was not authoritative because the no-install review worktree resolved root [email protected] for untouched packages/terminal-core, while that workspace requires and the canonical checkout contains [email protected]. Exact-head CI remains the typecheck gate.
  • Autoreview of the uncommitted maintainer delta: clean, no accepted/actionable findings.
  • Autoreview of the full rebased branch against origin/main: clean, no accepted/actionable findings.

LOC delta

  • Production: +135 / -8 (net +127)
  • Tests and QA harness: +582 / -5
  • Docs: +21 / -0
  • Test config: +5 / -4
  • Total: +743 / -17

The positive production delta establishes the missing registry ownership and durability boundary. It avoids reconstructing requester identity downstream after admission has already lost it.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: M labels Aug 7, 2026
@wonfong
wonfong marked this pull request as ready for review August 7, 2026 08:19
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 7, 2026
@clawsweeper

clawsweeper Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 9:40 AM ET / 13:40 UTC.

ClawSweeper review

What this changes

The PR makes a default-delivery plugin follow-up reuse a self-yielded subagent run so its completion reaches the original waiting requester.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep 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
Reviewed head: 99496dd6826443d8076d71ba77e8f6e69441d6e2

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Strong exact-head boundary proof and focused owner-boundary repair, with the normal state-and-delivery merge risk retained.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body supplies exact-head proof through a real ephemeral Gateway with a mock channel and provider, showing the post-fix quiet yield followed by one original-requester delivery.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies exact-head proof through a real ephemeral Gateway with a mock channel and provider, showing the post-fix quiet yield followed by one original-requester delivery.
Evidence reviewed 5 items Current-main defect: Current main always calls normal registration for plugin subagent runs, so an unrequested follow-up receives the child agent's main-session requester rather than adopting a paused owner.
Admission-time owner transfer: The PR selects a sessions_yield-paused row and replaces it before provider execution, preserving the appropriate owner boundary.
Durability and rollback: The replacement remaps the requester wake batch, persists the delete/upsert before starting its waiter, and restores the paused source if persistence fails.
Findings None None.
Security None None.

How this fits together

Plugin 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]
Loading

Before merge

  • Resolve merge risk (P1) - This changes persisted paused-run ownership and completion routing; a regression could leave a requester waiting or deliver a result to the wrong session, so retain the exact-head Gateway and registry checks through merge.
  • Complete next step (P2) - No repair lane is needed: the exact-head review found no actionable defect, leaving normal merge handling as the next action.
Agent review details

Security

None.

PR surface

Source +420, Tests +284, Docs +21, Other +1. Total +726 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 13 430 10 +420
Tests 5 287 3 +284
Docs 1 21 0 +21
Config 0 0 0 0
Generated 0 0 0 0
Other 1 5 4 +1
Total 20 743 17 +726

Review metrics

Metric Value Why it matters
Production versus test LOC production +135/-8; tests and QA +582/-5 The production growth establishes a durable registry ownership boundary, while the larger test delta covers delivery, restart, sibling, and rollback cases.

Stored data model

Persistent data-model change detected: serialized state: extensions/qa-lab/test-fixtures/self-yield-followup-subagent-plugin/index.js. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #120157
Summary: This PR is the concrete candidate fix for the linked paused-subagent follow-up delivery defect.

Members:

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

Merge-risk options

Maintainer options:

  1. Land with the exact-head safeguards (recommended)
    Accept the bounded ownership-state risk after GitHub retains the clean merge and required checks for this exact head.

Technical review

Best 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.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head proof through a real ephemeral Gateway with a mock channel and provider, showing the post-fix quiet yield followed by one original-requester delivery.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies exact-head proof through a real ephemeral Gateway with a mock channel and provider, showing the post-fix quiet yield followed by one original-requester delivery.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A default plugin follow-up can otherwise leave an agent workflow waiting indefinitely without its child result.
  • merge-risk: 🚨 session-state: The patch transfers and persists paused subagent-run ownership across gateway run IDs.
  • merge-risk: 🚨 message-delivery: The patch changes which requester receives the completed follow-up result.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies exact-head proof through a real ephemeral Gateway with a mock channel and provider, showing the post-fix quiet yield followed by one original-requester delivery.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head proof through a real ephemeral Gateway with a mock channel and provider, showing the post-fix quiet yield followed by one original-requester delivery.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the fail-closed paused-run persistence correction and requested the exact-head re-reviews. (role: recent durability correction author and reviewer; confidence: medium; commits: 15f240076105, 99496dd68264; files: src/agents/subagent-registry-run-manager.ts, docs/tools/subagents.md)

Rank-up moves

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

  • Retain GitHub's clean merge and exact-head required checks if the branch is refreshed against current main.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (5 earlier review cycles)
  • reviewed 2026-08-07T09:40:02.940Z sha 92068e255ccabbfb28fa2cdcb447e78612625cd7 :: needs real behavior proof before merge. :: [P1] Preserve the paused owner after a requester-bound follow-up | [P2] Limit the follow-up documentation to default delivery
  • reviewed 2026-08-07T16:43:20.046Z sha ea4b46c8ccb7047bc6472a6f68dcf448188ea325 :: needs real behavior proof before merge. :: [P2] Limit continuation docs to plugin runtime follow-ups
  • reviewed 2026-08-08T02:55:51.358Z sha eddfe3b1416d4e0b1325b9ab4c2d818452db2567 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T03:50:07.597Z sha eddfe3b1416d4e0b1325b9ab4c2d818452db2567 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T05:39:19.174Z sha 9f131d81c7f80e9e198e4f346c8fc0d61f43e7c6 :: needs real behavior proof before merge. :: [P2] Scope the continuation exclusion to untracked routes

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 7, 2026
@steipete
steipete force-pushed the fix/subagent-yield-followup-adoption branch from 2457ba5 to eddfe3b Compare August 8, 2026 02:05
@steipete steipete self-assigned this Aug 8, 2026
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Exact head eddfe3b1416d4e0b1325b9ab4c2d818452db2567 addresses both prior rank-up moves: the docs now scope continuation to default-delivery api.runtime.subagent.run, and the PR body includes the exact-head mock-gateway verdict JSON. Maintainer review also made paused-run adoption fail closed on persistence errors and trimmed duplicate tests.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 8, 2026
@steipete
steipete force-pushed the fix/subagent-yield-followup-adoption branch from eddfe3b to 9f131d8 Compare August 8, 2026 04:49
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 8, 2026
@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 8, 2026
wonfong and others added 6 commits August 8, 2026 19:18
…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]>
@wonfong
wonfong force-pushed the fix/subagent-yield-followup-adoption branch from 9f131d8 to 15f2400 Compare August 8, 2026 11:18
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Exact rebased head 15f2400761053eec9998b7d445cb5d19cdc25455 is patch-identical to the previously reviewed repair, is based on de9314301f0582d4eada9e24168b499608c51b26, and has refreshed focused plus mock-gateway proof. The PR body now contains the exact-head verdict JSON. Please review this SHA and its current checks.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Exact head 99496dd6826443d8076d71ba77e8f6e69441d6e2 includes the requested documentation clarification, is based on de9314301f0582d4eada9e24168b499608c51b26, and has refreshed exact-head mock-gateway proof. The PR body now contains the exact-head verdict JSON. Please review this SHA and its current checks.

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 8, 2026
@steipete
steipete merged commit 9fdc266 into openclaw:main Aug 8, 2026
270 of 275 checks passed
@steipete

steipete commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: runtime.subagent.run follow-up on a sessions_yield-paused subagent never wakes the original parent

2 participants