Repository navigation
fix(subagents): wake requesters when children pause for continuation - #161114
Conversation
Deliver one pending pause notice through the requester-settle owner while preserving the child's completion cohort and the requester's authority. Keep admitted pause turns authorized until their own scope closes, and fence obsolete notices on continuation, reset, and cancellation. Retain compatibility through an optional registry JSON field, update the tool contract, and cover delivery, persistence, authority, and live resume.
|
🦞👀 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. Reviewed September 30, 2026, 1:11 AM ET / 05:11 UTC (Revision 11). ClawSweeper reviewWhat this changesThe branch records a child’s pause notice, wakes its requesting agent with continuation details, binds the resulting Gateway turn to that requester, and updates documentation and tests. Merge readiness✅ Ready for maintainer review Current main still leaves a requester waiting when a child pauses for a message. This PR addresses that distinct behavior, and the reviewed head has no supported blocking finding. Priority: P1 Review scores
Verification
How this fits togetherSubagents report their state to a registry, which schedules messages back to the agent that requested their work. A paused child can then receive a continuation through sessions.send and later deliver its final result. flowchart LR
A[Child waits for message] --> B[Registry records pause]
B --> C[Requester wake queue]
C --> D[Gateway checks requester authority]
D --> E[Requester receives notice]
E --> F[Continuation sent to child]
F --> G[Final completion delivered]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +315, Tests +1032, Docs +11. Total +1358 across 40 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one durable pause notice per paused child, preserve its later completion, and enforce requester authority at Gateway input admission. Do we have a high-confidence way to reproduce the issue? Yes. The current-main wake path waits on the paused child, and the PR records the original pause-wake regression failing before the fix; I did not execute it in this read-only review. Is this the best way to solve the issue? Yes. The branch uses the existing registry, requester-settle delivery and Gateway admission owners, with focused compatibility and final-effect evidence. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against bcd3cace1911. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
The requester's wake message already explains how to continue a paused child, so the always-visible yield tool only needs to say the requester is notified. Refresh prompt snapshots.
|
|
Completed the approved third normal merge-main refresh. Current head is This incorporates main repair Merged-tree validation:
The earlier two refreshes incorporated main's trusted manifest export and lint repairs, addressing CI runs ClawSweeper revision 10 was clean on the previous head |
|
Merged via squash.
|
…penclaw#161114) A child yielding with sessions_yield waitFor:message now wakes its waiting requester once with the child identity and continuation details. The existing requester-settle owner persists and consumes the pause obligation, preserves the paused child and later completion, and fences stale notices after continuation. Gateway admission binds captured requester dispatch to the actual run, session and source before input effects, denying foreign or reset requester targets without granting Cron authority. The optional durable JSON field preserves the released codec contract without a SQL migration; the maintainer approved the production-LOC exception. Recorded validation covers a live pause → requester wake → sessions.send continuation → one completion flow, real Gateway/SQLite negative authority proof, fixture regressions, core types, lint and prompt snapshots. The three approved merge-main refreshes preserve all 40 original PR file blobs and incorporate main's CI harness and settlement-fixture repairs. The final merged-tree settlement file passes all seven cases, with core types and diff checks passing. Detailed proof and release-note context remain in openclaw#161114. Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Fixes a waiting requester remaining idle when its unfinished child calls
sessions_yieldwithwaitFor: "message"and needs a continuation.User Impact
The requester receives one clearly identified pause notice containing the child session key, run ID, label and acknowledgment. It can continue that child with
sessions_send; the later real completion still arrives normally. A later requester yield does not replay a consumed pause notice.Acknowledgments are trimmed and bounded to 12,000 UTF-16 code units, matching announce completion delivery's retained-text limit. Missing text becomes
Paused awaiting continuation.The existing prompt-data escaping treats acknowledgments as data. Cron, collector, A2A and the child'swaitForsemantics remain unchanged.Why This Change Was Made
An optional
pauseNoticein the existing requester-wake JSON records the pending obligation. Existing requester-settle delivery owns queueing, retries, idempotency and authority checks. Notice consumption preserves the paused child and its completion cohort; continuation fences the old notice. The pause turn retains its authority independently of the later completion grant.Final-effect proof exposed another defect: a captured requester dispatch could target a foreign session, lose its optional Cron admission, and still start a Gateway turn with the original operator authority. The existing requester authority owner now binds the actual run, session and source before input admission. Its captured live assertion also runs at the pending-input commit boundary. Successful operator-only admission consumes the transient dispatch without granting Cron management.
Upgrade/rollback: the additive optional durable field is explicitly approved. There is no DDL, new table, schema-version bump or migration. The published
v2026.9.6codec and normalizer loaded and round-tripped synthetic public and parent-only rows containing the field unchanged. Existing paused rows are not backfilled. A rolled-back runtime can ignore or consume the optional notice through its existing wake lifecycle; it does not provide the new pause-notification guarantee. Task and completion fields remain compatible.Evidence
Final head:
f467702291f8ca43512bfb362b99e326f9fee1e5. All 84 final focused cases and the live pause → requester wake →sessions.sendcontinuation → one completion pass after the latest merge. Fresh independent P1 autoreview isscoped-clean(394.87 s wall), with no actionable P0/P1 findings. ClawSweeper revision 8 reviewed2adbe8c136d69as ready for maintainer review, with sufficient real-behavior proof and no code, security or before-merge findings. The final commit changes only the two CI test fixtures described below; production code, docs and snapshots are byte-identical to that reviewed head. Exact-head review and CI for the final test-fix commit are tracked separately; earlier passing live/production proof remains applicable to its identical production source. No merge or auto-merge is requested.9bb19442cebbpnpm tsgo:corepnpm prompt:snapshots:genpnpm prompt:snapshots:checkgit diff --checkGateway runner duration was 212.47 s and the other three suites together took 509.20 s; combined wall includes compiler preparation and cleanup. Broad
check-changedwas not run. No test was skipped, weakened or given a longer timeout for this change.The second merge incorporated
9bb19442cebb121c1b066968f106a1e6886f6ad4after main advanced during review. Only the three generated prompt snapshots conflicted; all seven were regenerated through their owner. The admission source auto-merge preserves both main's consolidated cleanup and the new target/input assertions. Main's terminal-cleanup persistence changes were retained and covered by the repeated completion and live proof. The lockfile was unchanged, so no reinstall was needed for this merge.Integrated main
55bb2ccf0a08dd889fddafb7c5566155f19c45b3with a merge commit; no rebase or force-push. The changed lockfile was installed withpnpm install --frozen-lockfile(16.3 s reported by pnpm).Conflict resolutions preserve both behaviors:
subagent-announce.requester-settle-wake.ts: keep main's asynchronous descendant/source validation while allowing pause notices before sibling completion.subagent-completion-mutation.kernel.ts: consume only the paused member's notice while preserving full-cohort completion checks and main's CAS/reconciliation.subagent-registry-lifecycle-wake.ts: retain the asynchronous mutation/commit owner and pause-identity fencing.subagent-registry-public-api.ts: await hydration and preserve caller/source fences around asynchronous pause publication.subagent-registry-requester-yield.ts: retain main's initial-transfer stages, preserve the notice, and schedule only after release.subagent-announce.requester-settle-dispatch.test.ts: retain both sets of imports and await main's asynchronous settle operations.subagent-announce.requester-settle-fixture.test-support.ts: retain both fixture contracts and await the merged yield/settle owners.subagent-registry.test.ts: preserve both recovery histories and await the asynchronous pause/restore operations.requester-cron-authority.test.ts: preserve main's async handoff assertions and the pause-then-completion authority regression.The original pause-wake regression failed against the original main baseline with the production change stashed (141.12 s wall):
node scripts/run-vitest.mjs src/agents/subagents/announce/subagent-announce.requester-settle-pause.test.ts --maxWorkers=1 -t 'wakes once for a paused child'The stronger foreign-requester regression failed against the integrated code before the final authority repair (133.19 s wall):
node scripts/run-vitest.mjs src/gateway/server.requester-pause-authority.test.ts --maxWorkers=1 -t 'foreign requester'This test keeps the outer captured parent identity unchanged and changes the actual registered
agentRPC target. The negative cases use the real Gateway handler, canonical caller admission and real SQLite stores; only provider execution is simulated. They observe no execution start, provider call, transcript change, pending input or accepted dedupe entry for a foreign target or requester reset during pending-input staging. The positive cases cover both an admin with Cron-management entitlement and an operator without that entitlement, after consuming the pause notice.The allowed end-to-end flow is separately proven with a real isolated Gateway and live provider. The marker is released only to the child after the parent yields; the same child session then resumes through
sessions.sendand delivers exactly one completion. The supplied credential file is sourced only in that shell, and state starts in a fresh task-owned directory.The first integrated live run passed in 371.912 s test time / 649.45 s wall. Final validation results are reported above.
Production LOC: +265 at the earlier review → +315 against integrated main (426 added / 111 removed, excluding tests and test helpers). The maintainer explicitly accepted the LOC exception; neutrality is no longer a gate. The added production code is limited to durable pause obligations, the existing delivery/authority owners, and the Gateway admission binding.
The integrated focused group ran the requester pause/wake/dispatch, authority, requester-wake/expired-receipt store, initial-transfer and yield-tool-owner suites: 61 infra cases passed; the agents group initially had 139 passes and eight fixture failures from a removed store-reader import (1021.93 s wall). Restoring that required import fixed the observer and replay assertions; the affected requester-wake suite then passed all 42 cases (487.35 s wall). No assertions were loosened. The
sessions-yield-tool.test.tssuite passed 14 cases (26.65 s wall). These commands usednode scripts/run-vitest.mjs <files> --maxWorkers=1.The suite-level Gateway proof is necessary because scope predicates alone cannot establish denial before actual input persistence and execution. Compilation/import time dominates these runs on the shared host. No per-case Gateway boot, added timer, polling loop or timeout increase was introduced.
All test/tool runs used
/private/tmp/oc-yp; autoreview used macOS-private temporary storage as required. The pnpm 12.6.0 host binary waited on a foreign-owned global store lock before live-test startup (448.33 s, stopped without touching the lock). The already-installed package.json-pinned pnpm 12.5.1 was then selected through the live wrapper's supportednpm_execpathmechanism. No dependency, lock, guard, baseline or budget override was made.Earlier attempts hit host compilation contention and a remote source-freeze stall; neither supplied passing proof, and their retained ownership state was left intact. Broad
check-changedwas omitted within the work-order budget. No CI workflow was dispatched or rerun for proof.A final Gateway proof iteration passed allowed, operator-only and reset cases, and correctly rejected the foreign request, but its test join surfaced the expected tracked rejection before the no-effect assertions (692.46 s wall). The fixture now joins all tracked tasks with
allSettled, verifies each rejected task contains the expected authority-denial error, and preserves every no-effect assertion. The optional-true fixture field was corrected at the same time. The interrupted broader user-turn attempt (793.67 s) reached no assertions and is not counted as passing proof.CI on the preceding reviewed head
b44100c4f2b10failed; this is prior-head evidence, not a current-head CI result. Run 36657879815, job 109706343948 failedtest/scripts/ci-changed-node-test-plan.source-owners.test.tsin the operator-authority helper owner case: expected[], received["src/gateway/server.mcp-session-owner.test.ts"](175 other tests passed). Fail-fast cancelled sibling coverage. The job checked out merge58a0f36fonto main750a5a8e7ffad3e8ff7f82a64da4fdc0c59d99ec. Main commit53c39cdb7b071(#154239) introduced that MCP test and its direct import of the operator-authority helper; the main proof inventory does not list it, and the owner expectation excludes it. The MCP test is absent from this PR head's own tree, and this PR changes none of the planner, expectation, inventory or helper inputs. This is source-based attribution to newer main; no main-only test rerun is claimed. No guard/test expectation was changed and no workflow was rerun. Dependency and security review both pass. ClawSweeper revision 6 subsequently accepted the proof with no code/security findings; a new review must bind the final merged head.CI fixture repairs on the final commit: run
36660554500on2adbe8c136d69failed two affected fixtures (jobs109714486131and109714486238). These were not attributed to main. The registry restore override omitted the existingbindWakeMutationfixture binding, causing its synthetic memory-only row to reach real SQLite and correctly fail settlement; adding the binding preserves the original revoked-wake, paused-row and no-outcome assertions. Thesessions.sendfixture directly creates a legacy paused row without a notice: the cohort now stays pending without a completion retry until continuation, and actual completion dispatches immediately. The test requires that parked state and one immediate combined completion, retaining both result texts and full wake retirement. Obsolete timer/deadline machinery was removed; no production changes, broader mocks, timeout increases or guard/baseline edits were made.The final two-file replay passed all 124 cases (8
sessions.send+ 116 registry), including both CI failures, in 293.93 s wall:Their changed type graphs passed in 124.87 s wall (lane times 4.0/5.7 s), core-lane lint passed in 90.80 s, oxfmt and working/staged diff checks passed, and fresh P1 review of the final test-only correction was scoped-clean (311.07 s). The first fixture replay exposed the remaining obsolete post-completion deadline expectation (412.39 s); the final replay requires delivery without advancing time or scheduling a synthetic sweep. New-head CI remains a separate gate; no passing CI result is claimed until it completes.
Final-head CI blocker: run 36662936238, preflight job 109721402966 failed before tests in
Build CI manifest:The job used workflow/merge
606b22cd73cabc1906ef86d2e640b7b94fb47742(merging this head into main12253cc5192dd0f0219e61ba410f8206ecee6378). Main's9d75a8fe87af5(#161534) introduced the script invocation; the script exists in that main commit, but preflight's trusted-harness export list copies the actions, node setup and release-context/version helpers without the manifest script. This PR changes no workflow or script files. The work order forbids.github/guard changes, so this inherited harness defect is left to its owner; no bypass or workflow rerun was attempted. Current-head CI is blocked and its test jobs did not run. Final localpnpm tsgo:corealso passed again (8.10 s wall).