Skip to content

fix(agents): resume parent after late subagent completion - #119696

Merged
vincentkoc merged 1 commit into
mainfrom
fix/qa-subagent-yield-rearm-20260805
Aug 5, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/qa-subagent-yield-rearm-20260805

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Related: #110922
Related: #118703
Related: #92433

What Problem This Solves

Fixes a timing race where a parent agent could remain silent after all delegated subagents completed when a requester yield crossed child completion delivery.

The exact subagent-fanout-synthesis QA lane completed both child tasks but never produced the parent's final synthesis.

Root Cause

An alpha-child cleanup could admit a requester wake before sessions_yield. While that wake awaited registry runtime loading, requester settlement replaced the row with a new yielded-batch generation. The stale alpha wake then adopted the newer generation, saw beta still settling, and persisted a 30-second defer. Beta cleanup correctly honored that durable deadline, delaying the only valid final wake.

Why This Change Was Made

Requester wakes are now fenced to the rearm generation they admitted before their first await. A stale wake returns before descendant inspection or batch mutation when requester settlement has installed a newer generation.

Settlement still marks delivered or in-progress completions as requiring a visible reply after yield, but it schedules immediately only when every ended delivery is fully delivered. Mixed batches remain owned by the normal delivery cleanup boundary. Existing transport retry deadlines and descendant defers are unchanged.

User Impact

Parents resume once, promptly, after late subagent delivery completes instead of hanging or waiting on a stale 30-second deadline. Duplicate-wake protection and legitimate retry backoff remain intact.

Evidence

  • Reproduced on QA Lab run https://github.com/openclaw/openclaw/actions/runs/31029147516 at a3419d4a4b4c894b47a9273181735d091f4d502f.
  • Added a production-composition lifecycle regression that gates the stale alpha wake across requester yield, proves it cannot write nextAttemptAt, and proves beta cleanup owns one immediate final wake.
  • Focused requester-yield, requester-wake, lifecycle, retry-grace, announce-delivery, and overflow-compaction suites: 352 passed.
  • Exact behavior head ee74ca5554f9d6e2be355353c3a196a206c36c6c passed subagent-fanout-synthesis on direct AWS: Anthropic 3/3 and OpenAI 1/1; every report passed, every CLI exit was 0, and aggregate exit was 0.
  • Current exact head fa6f97d5fdcfaf34de8a765600a639f7e843266a adds only the test type narrowing required by check-test-types; its focused lifecycle file passes 10/10.
  • Direct Codex contract check at bb1af235ea2822d7a40f75ef52e4d6a2cde84da2: codex-rs/core/src/agent/status.rs, session_prefix.rs, agent/control.rs, tools/handlers/multi_agents/wait.rs, and multi_agents_spec.rs confirm completed child final messages are surfaced to the parent and wait reports terminal status.
  • git diff --check: passed.
  • Autoreview: clean, correctness 0.98.
  • Production delta: +7/-3. Tests: +192/-15.

Punchcard-Session: silver-valley-valley-dt

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Aug 5, 2026
@vincentkoc vincentkoc self-assigned this Aug 5, 2026
@vincentkoc
vincentkoc force-pushed the fix/qa-subagent-yield-rearm-20260805 branch from e4264e2 to ee74ca5 Compare August 5, 2026 18:55
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review exact head ee74ca5554f9d6e2be355353c3a196a206c36c6c. The previous public placeholder is tied to superseded head e4264e20d0236724732fda35be6e778d0a0c57eb.

Exact-head QA evidence is now complete: subagent-fanout-synthesis passed Anthropic 3/3 and OpenAI 1/1 on direct AWS; every report passed, every CLI exit was 0, and aggregate exit was 0. The PR body contains the deterministic lifecycle regression and focused-suite evidence.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper

clawsweeper Bot commented Aug 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 5, 2026, 3:29 PM ET / 19:29 UTC.

ClawSweeper review

What this changes

The PR prevents a requester wake admitted before a yield re-arm from mutating the newer subagent-completion batch after lazy runtime loading.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep open for maintainer review. The generation fence appears to repair the stale-wake ownership race without a diff-introduced correctness finding, but this MEMBER-authored draft has the protected maintainer label and the required sibling Codex source was unavailable for direct contract verification.

Priority: P1
Reviewed head: ee74ca5554f9d6e2be355353c3a196a206c36c6c
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with strong regression design, pending protected maintainer review and independently accessible exact-head evidence.
Proof confidence 🌊 off-meta tidepool Not applicable: The external-contributor proof gate does not apply because the PR author is a repository MEMBER; the body nevertheless records exact-head direct-AWS runtime evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor proof gate does not apply because the PR author is a repository MEMBER; the body nevertheless records exact-head direct-AWS runtime evidence.
Evidence reviewed 7 items Current-main gap: Current main checks only whether wake state exists after lazy runtime loading, so it can operate on a state generation installed during that await.
Owner-boundary repair: The PR snapshots the admitted generation before the await and returns before descendant inspection or batch mutation when the durable row was re-armed.
Lifecycle contract: Requester settlement creates a new generation for yielded batches, while the lifecycle keeps a pending re-arm when wake work is already running.
Findings None None.
Security None None.

How this fits together

Subagent completion delivery persists requester wake state after delegated agents finish. The lifecycle scheduler consumes that state to start one follow-up parent turn, allowing the parent to synthesize child results.

flowchart LR
  A[Child agents finish] --> B[Completion delivery]
  B --> C[Requester yield settlement]
  C --> D[Wake generation recorded]
  D --> E[Lifecycle wake decision]
  E --> F[Parent synthesis reply]
Loading

Decision needed

Question Recommendation
Should this protected draft proceed after a maintainer independently verifies the exact-head QA result and direct Codex runtime contract? Verify then proceed: Review the exact Codex contract and the linked exact-head QA artifact, then decide the draft through normal maintainer merge gates.

Why: Repository policy requires direct Codex source inspection for Codex-related verdicts, but the required checkout was unavailable in this review environment.

Before merge

  • Resolve merge risk (P1) - The exact-head external QA artifact and direct sibling Codex contract source were unavailable to this read-only review, so a human must not treat the reported runtime result as independently verified here.
  • Complete next step (P2) - The patch has no mechanical repair finding, but its protected maintainer draft status and unavailable direct Codex contract evidence require human review rather than automation.
Agent review details

Security

None.

PR surface

Source +4, Tests +174. Total +178 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 7 3 +4
Tests 2 189 15 +174
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 196 18 +178

Review metrics

Metric Value Why it matters
Production versus test LOC production +7/-3 (net +4); tests +189/-15 (net +174) The small production increase is justified by a durable generation-ownership invariant, with focused ordering regressions covering it.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the pre-await generation fence and land only after a maintainer reviews the exact head with the required Codex source contract and normal merge gates available.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the pre-await generation fence and land only after a maintainer reviews the exact head with the required Codex source contract and normal merge gates available.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: a wake can await runtime loading while requester yield installs a newer generation; the added composition test encodes that ordering. The reported direct-AWS reproduction was not independently accessible here.

Is this the best way to solve the issue?

Yes for the identified race: fencing at the pre-await wake boundary prevents stale descendant inspection and deadline writes, whereas a downstream callback guard would leave the stale mutation path reachable.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against e69c3df2361b.

Labels

Label changes:

  • add P1: A parent-agent completion race can leave a delegated workflow without its final synthesis response.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply because the PR author is a repository MEMBER; the body nevertheless records exact-head direct-AWS runtime evidence.

Label justifications:

  • P1: A parent-agent completion race can leave a delegated workflow without its final synthesis response.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor proof gate does not apply because the PR author is a repository MEMBER; the body nevertheless records exact-head direct-AWS runtime evidence.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged parent-handoff repair that established the requester-settlement ownership model, and current wake-path history carries through this area. (role: recent area contributor; confidence: high; commits: bf2da1ce1af7, 4511c9b71f78; files: src/agents/subagent-announce.requester-settle-wake.ts, src/agents/subagent-registry-lifecycle-requester-wake.ts)
  • vincentkoc: Authored the merged yielded-fanout refinement on the same requester-yield and wake-generation surface. (role: recent area contributor; confidence: high; commits: 05c987ccec4c; files: src/agents/subagent-registry-requester-yield.ts, src/agents/subagent-registry.lifecycle-retry-grace.e2e.test.ts)

Rank-up moves

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

  • Have a maintainer inspect the linked exact-head QA result and direct sibling Codex runtime contract before changing draft or merge status.

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.

@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

Run a fresh review for the current PR head ee74ca5554f9d6e2be355353c3a196a206c36c6c. The prior command resolved only to a stale-head status for e4264e20d0236724732fda35be6e778d0a0c57eb; it did not review the current head.

@clawsweeper

clawsweeper Bot commented Aug 5, 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 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. P1 High-priority user-facing bug, regression, or broken workflow. labels Aug 5, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review August 5, 2026 19:35
Punchcard-Session: silver-valley-valley-dt
@vincentkoc
vincentkoc force-pushed the fix/qa-subagent-yield-rearm-20260805 branch from ee74ca5 to fa6f97d Compare August 5, 2026 19:45
@vincentkoc
vincentkoc merged commit 2db3431 into main Aug 5, 2026
128 checks passed
@vincentkoc
vincentkoc deleted the fix/qa-subagent-yield-rearm-20260805 branch August 5, 2026 19:59
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit to VACInc/openclaw that referenced this pull request Aug 5, 2026
…cope

* origin/main:
  fix(qa): report cleanup failures truthfully (openclaw#119727)
  fix: keep completed actions visible after settled finalization (openclaw#119726)
  fix(agents): rearm yielded requester wake (openclaw#119696)
  fix(diagnostics): preserve telemetry during service shutdown (openclaw#119705)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 6, 2026
Punchcard-Session: silver-valley-valley-dt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P1 High-priority user-facing bug, regression, or broken workflow. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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