Skip to content

fix(agents): plugin follow-up admitted during a sub-agent's yield never reaches the requester - #164101

Merged
steipete merged 1 commit into
mainfrom
steipete/yield-followup-race-adoption
Oct 3, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/yield-followup-race-adoption

Conversation

@steipete

@steipete steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

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.run continues a child that is still finishing its sessions_yield turn.

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)
  • A follow-up that finishes before the pause publishes is not adopted; that needs a full model turn to complete within one registry write.
  • A Gateway restart between pause publication and adoption has no recovery-time adoption.
  • Operator sessions.send continuations 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.

  • Reproduced on main first (tbx_01m3ze5z7x2b0skapv1cpyk5hz, fixture no longer masking): plugin-subagent-self-yield-followup.e2e.test.ts failed 2/2 — the follow-up marker never reached the requester within 90 s, and the only extra outbound message answered a requester-settle:…:pause turn.
  • E2E with the fix (tbx_01m3zkwztt0bt0ekjqcm2nj1hp, OPENCLAW_BUILD_PRIVATE_QA=1 OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm build, then CI=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.
  • Regression at the owner (subagent-registry-yield-followup-adoption.test-support.ts, registered by subagent-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.
  • Siblings: queued registration, Gateway plugin-subagent admission (agent-run-subagent, agent.test.ts), requester-settle pause/cancel, task replacement, completion authority, replacement cleanup, and requester-yield suites passed.
  • After rebasing onto 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), and check:changed passed on the final head (tbx_01m4060r3xwn5y2g0dr39ckys6).
  • node scripts/check-changed.mjs also passed before the rebase (typecheck, lint, ratchets, changed tests). Codex autoreview (P0–P2) scoped-clean.

…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.
@clawsweeper

clawsweeper Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling extensions: qa-lab size: L labels Oct 3, 2026
@steipete
steipete marked this pull request as ready for review October 3, 2026 06:45
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 3, 2026
@clawsweeper

clawsweeper Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 3, 2026, 2:51 AM ET / 06:51 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 1c17b83f6ac71ac06d635230879d51b3d2a35f01

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful before/after boundary evidence and no actionable introduced defect.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The captured Testbox evidence exercises authenticated plugin admission, a held yielding child, the production registry, and requester announcement through an ephemeral Gateway. With the masking hook removed, the recorded after-fix result is one completion reply, no pause notice, and no duplicates after restart. Scoped policy permits this isolated Gateway boundary proof; no stored-data format changes require migration.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The captured Testbox evidence exercises authenticated plugin admission, a held yielding child, the production registry, and requester announcement through an ephemeral Gateway. With the masking hook removed, the recorded after-fix result is one completion reply, no pause notice, and no duplicates after restart. Scoped policy permits this isolated Gateway boundary proof; no stored-data format changes require migration.
Evidence reviewed 8 items Pinned introduced change: Reviewed the merge-base-to-head hunks. Adoption is invoked after pause publication by both lifecycle observers and after default plugin registration, covering either publication order. Explicit requester registration remains separate.
Current main still needs the repair: Fetched main only attempts adoption before registration; it lacks the post-registration successor adoption. Its recovery manager likewise lacks the new successor operation. This does not establish an implemented-on-main close or a shipped fix.
Existing owner and guarded adoption: The new operation reuses transactional replacement. It rechecks the paused source and running successor after serialization, excludes completion-bearing, collecting, cancelled, and requester-bound successors, preserves live execution, and remaps the settlement batch.
Findings None None.
Security None None.

How this fits together

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

Before merge

None.

Agent review details

Security

None.

PR surface

Source +125, Tests +202, Docs +7. Total +334 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 5 132 7 +125
Tests 6 311 109 +202
Docs 2 7 0 +7
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 450 116 +334

Review metrics

Metric Value Why it matters
Owner repair growth production net +125 lines; tests and QA net +202 lines Production growth implements the missing race handoff through the existing replacement owner; the tests remove masking delivery and cover both publication orders.

Technical review

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

Labels

Label changes:

  • add P1: The established plugin continuation workflow can silently lose the result owed to the original requester.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured Testbox evidence exercises authenticated plugin admission, a held yielding child, the production registry, and requester announcement through an ephemeral Gateway. With the masking hook removed, the recorded after-fix result is one completion reply, no pause notice, and no duplicates after restart. Scoped policy permits this isolated Gateway boundary proof; no stored-data format changes require migration.
  • 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 captured Testbox evidence exercises authenticated plugin admission, a held yielding child, the production registry, and requester announcement through an ephemeral Gateway. With the masking hook removed, the recorded after-fix result is one completion reply, no pause notice, and no duplicates after restart. Scoped policy permits this isolated Gateway boundary proof; no stored-data format changes require migration.

Label justifications:

  • P1: The established plugin continuation workflow can silently lose the result owed to the original requester.
  • 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 captured Testbox evidence exercises authenticated plugin admission, a held yielding child, the production registry, and requester announcement through an ephemeral Gateway. With the masking hook removed, the recorded after-fix result is one completion reply, no pause notice, and no duplicates after restart. Scoped policy permits this isolated Gateway boundary proof; no stored-data format changes require migration.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Testbox evidence exercises authenticated plugin admission, a held yielding child, the production registry, and requester announcement through an ephemeral Gateway. With the masking hook removed, the recorded after-fix result is one completion reply, no pause notice, and no duplicates after restart. Scoped policy permits this isolated Gateway boundary proof; no stored-data format changes require migration.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • wonfong: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

@steipete
steipete merged commit d6b1cc8 into main Oct 3, 2026
207 of 212 checks passed
@steipete
steipete deleted the steipete/yield-followup-race-adoption branch October 3, 2026 07:03
@steipete

steipete commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 4, 2026
…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.
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 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.

1 participant