Repository navigation
fix(agents): plugin follow-up admitted during a sub-agent's yield never reaches the requester - #164101
Conversation
…still yielding A default-delivery plugin follow-up (api.runtime.subagent.run on the paused session, no requester) admitted while the child was still inside its sessions_yield turn registered as a sibling owing no completion, while the kickoff row paused with the original requester's obligation. The requester never received the follow-up's result. The registry now hands the pause to that follow-up from whichever commit lands second: after the yield pause publishes (lifecycle listener and wait observer) and after a default-delivery sibling registers at Gateway admission. Adoption reuses the existing replacement operation in a new successor mode that keeps the follow-up's live execution and transfers the requester, task lineage, completion custody, cron authority, and settle-wake without the pause notice. Requester-bound follow-ups keep their own delivery; completed rows are never absorbed. The QA fixture no longer returns the follow-up reply from its own hook, so the e2e now proves the registry announcement.
|
🦞👀 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 October 3, 2026, 2:51 AM ET / 06:51 UTC. ClawSweeper reviewWhat this changesThe PR transfers a yielding sub-agent’s pending requester delivery to an already-admitted default plugin follow-up and removes a QA fixture reply that masked missing announcements. Merge readiness✅ Ready for maintainer review This PR addresses a distinct delivery race that current main and the related merged fixes leave unresolved. The pinned patch has no actionable correctness finding, and the supplied production-boundary evidence supports the intended result. Priority: P1 Review scores
Verification
How this fits togetherThe sub-agent registry tracks delegated work and its completion audience. Gateway plugin admission and child lifecycle events feed that registry, which later announces results or resumes the waiting requester. flowchart TD
A[Plugin follow-up] --> B[Gateway admission]
C[Child publishes yield] --> D[Sub-agent registry]
B --> D
D --> E{Independent requester?}
E -->|Yes| F[Separate delivery obligation]
E -->|No| G[Adopt pending completion]
G --> H[Announce result to original requester]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +125, Tests +202, Docs +7. Total +334 across 13 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep continuation ownership in the registry’s existing replacement transaction so the original requester receives the follow-up result exactly once. Do we have a high-confidence way to reproduce the issue? Yes: admit a default plugin follow-up while the child is held inside sessions_yield, then release the yield and observe requester delivery. Current-main source establishes the gap, and the captured body reports baseline failures; this read-only review did not execute it. Is this the best way to solve the issue? Yes: extending the existing registry replacement owner covers both race orderings while preserving explicit requester separation and completed-result retention. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9012bcd4644b. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…still yielding (openclaw#164101) A default-delivery plugin follow-up (api.runtime.subagent.run on the paused session, no requester) admitted while the child was still inside its sessions_yield turn registered as a sibling owing no completion, while the kickoff row paused with the original requester's obligation. The requester never received the follow-up's result. The registry now hands the pause to that follow-up from whichever commit lands second: after the yield pause publishes (lifecycle listener and wait observer) and after a default-delivery sibling registers at Gateway admission. Adoption reuses the existing replacement operation in a new successor mode that keeps the follow-up's live execution and transfers the requester, task lineage, completion custody, cron authority, and settle-wake without the pause notice. Requester-bound follow-ups keep their own delivery; completed rows are never absorbed. The QA fixture no longer returns the follow-up reply from its own hook, so the e2e now proves the registry announcement.
Related: #163814, #163352, #120187, #127836
What Problem This Solves
Fixes: a plugin follow-up's result never reaches the original requester when
api.runtime.subagent.runcontinues a child that is still finishing itssessions_yieldturn.User Impact
A plugin that continues a paused sub-agent with default delivery now gets the documented behavior even when its follow-up arrives a moment early: the requester is announced exactly once with the follow-up's result, and it is not woken with a pause notice for work that already continued. Follow-ups that name their own requester keep their own delivery, and completed results keep the retained delivery from #163352.
Why This Change Was Made
Paused-run adoption only recognized a pause that was already published. A follow-up admitted while the child was still inside its yielding turn registered as its own run that owes nobody a completion, and the kickoff run then paused while still holding the requester's completion. Nothing ever moved that obligation to the run doing the work. #163814 stopped the stale pause notice; this change moves the obligation itself.
The registry now hands the pause to that admitted follow-up from whichever commit lands second: right after the pause publishes (lifecycle listener and wait observer; the pause notice is skipped when it adopts), and right after a default-delivery follow-up registers at Gateway admission (closing the window between the adoption check and registration). It reuses the existing replacement operation in a successor mode that keeps the follow-up's live execution and carries over the requester, task lineage, completion custody, cron authority, and settlement wake without the pause notice. Only
sessions_yield-paused rows are absorbed, and only by a running sibling that owes no completion of its own.The QA fixture had masked this since #127836 by returning the follow-up's answer from its own kickoff hook. It now replies with a spawn acknowledgement only, so the e2e proves the registry announcement.
Known limits (unchanged behavior, recorded as follow-ups)
sessions.sendcontinuations do not register a run while the child is still yielding, so they likely share this race; separate change.Evidence
All suites ran on Blacksmith Testbox through
node scripts/crabbox-wrapper.mjs run.tbx_01m3ze5z7x2b0skapv1cpyk5hz, fixture no longer masking):plugin-subagent-self-yield-followup.e2e.test.tsfailed 2/2 — the follow-up marker never reached the requester within 90 s, and the only extra outbound message answered arequester-settle:…:pauseturn.tbx_01m3zkwztt0bt0ekjqcm2nj1hp,OPENCLAW_BUILD_PRIVATE_QA=1 OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm build, thenCI=1 OPENCLAW_E2E_USE_PREBUILT_DIST=1 OPENCLAW_E2E_WORKERS=1 node scripts/run-vitest.mjs run --config test/vitest/vitest.e2e.config.ts <file>): 3/3 passed, 68–78 s each. Verdict facts:sessionsYieldCalls 1, childModelRequests 2, requesterCompletionTurns 1, pauseNoticeRequests 0, visibleReplies 1, duplicateRepliesAfterQuietWindow 0, duplicateRepliesAfterGatewayRestart 0. The e2e assertions fix(agents): stale pause notice wakes the requester after a quick subagent follow-up #163814 wrote for the masking fixture now count the spawn acknowledgement plus the one announcement, and count pause notices by their prompt instead of by every non-child request.subagent-registry-yield-followup-adoption.test-support.ts, registered bysubagent-registry.test.ts): with the production files pinned back to the base (tbx_01m3zgzmw6y1bzwjjp4cay60e6), the raced-adoption case fails (paused row never adopted) and the post-pause sibling case fails (no adoption operation); the requester-bound guard and the existing adoption case pass both ways. All four pass with the fix.pnpm test src/agents/subagents/registry/subagent-registry.test.ts --maxWorkers=1: 20–26 s wall, Vitest 5.6–12 s for the existing 120-test suite; the new cases take 10–50 ms each, no timers or Gateway boots. Moving the adoption block into the support module shrinks the over-cap suite.agent-run-subagent,agent.test.ts), requester-settle pause/cancel, task replacement, completion authority, replacement cleanup, and requester-yield suites passed.ca77256127e6(includes fix(agents): stale pause notice wakes the requester after a quick subagent follow-up #163814): registry suite 120/120, siblings 568 tests in 10 files, e2e 2/2 with the same verdict (tbx_01m4035p04grvj2jhnqmtzzpj9), andcheck:changedpassed on the final head (tbx_01m4060r3xwn5y2g0dr39ckys6).node scripts/check-changed.mjsalso passed before the rebase (typecheck, lint, ratchets, changed tests). Codex autoreview (P0–P2) scoped-clean.