Repository navigation
fix(agents): finished subagent results dropped when a grandchild's delivery stays pending - #165987
Conversation
|
🦞👀 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. What this changesThe PR delivers finished subagent batches after the inactive-descendant wait expires, explains that descendant delivery remains pending, and preserves the spent wait across retries. Example: A parent yields while a grandchild’s delivery continuation remains pending.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Partial Merge readiness✅ Ready for maintainer review This PR remains useful: current main still discards finished results at the descendant-wait cap. The earlier retry finding is resolved, and no remaining actionable code defect was found. Priority: P1 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherSubagents return delegated work to the parent agent through a durable completion batch. The settlement owner waits for related work, then resumes the parent with retained results through the existing Gateway delivery path. flowchart TD
A[Finished child results] --> B[Durable completion batch]
B --> C[Check related descendants]
C --> D{Active work remains?}
D -->|Yes| E[Keep batch pending]
D -->|No| F{Descendant wait spent?}
F -->|Still waiting| E
F -->|Spent or fully settled| G[Resume parent with results]
G --> H[Retain ordinary delivery retry policy]
Technical reviewBest possible solution: Keep completion delivery in the existing settlement owner, retain its spent wait through retries, and describe the inactive-descendant exception in the announcement guide. Do we have a high-confidence way to reproduce the issue? Yes: current-main source still terminalizes the batch at ten inactive-descendant deferrals, and the supplied baseline Gateway run demonstrates the lost result. This read-only review did not execute a reproduction. Is this the best way to solve the issue? Yes: the repair uses the existing completion owner and ordinary retry budgets, preserves active-work and cancellation gates, and avoids a parallel recovery mechanism. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ae64a98a4eb1. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +26, Tests +108. Total +134 across 5 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 8, 2026, 11:08 PM ET / October 9, 2026, 03:08 UTC (Revision 5). |
…ant wait is spent An ended descendant whose own completion delivery never settles (its parent run died on a provider limit, or runs as a followup outside the registry) kept the requester's frozen batch deferring with no active descendant. After REQUESTER_SETTLE_WAKE_MAX_DEFERRALS the batch was terminalized as undelivered, dropping every completed result (openclaw#138632). Stop waiting and dispatch the drained batch instead.
The wake message is now built after the dispatch-time descendant check; a batch delivered after its descendant wait was spent says a descendant result was still undelivered and that a child may report again separately.
07dd2d5 to
ca0df48
Compare
Rebased onto Conflict: one, in
Tests on the new head:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Exact head
No hosted jobs were rerun, and no unrelated CI code was changed. The built Gateway before/after proof, retry negative controls, canonical tsgo, full build, and real gpt-5-mini smoke are recorded in the PR description. Paused for the maintainer's CI disposition. |
|
Follow-up on
Build command on each source: CI=1 OPENCLAW_BUILD_PRIVATE_QA=1 VITEST=1 NODE_OPTIONS=--max-old-space-size=8192 pnpm build qaRuntimeTest command on each source, with the captured CI shard environment: time -p node --import tsx scripts/ci-run-node-test-shard.mtsBoth reach This supersedes the earlier weaker 35/35 non-CI replay evidence. The startup-inspection failure is reproducibly inherited on the actual CI base; no PR source changes or pushes were made for this investigation. |
|
Maintainer override: every red job is inherited, with evidence below.
ClawSweeper is ready on this exact head, and the built-Gateway parent → child → grandchild proof is in the PR. |
|
Landed in e6c5f72. Thanks @Oldrich333! Verified on a built Gateway with a real parent → child → grandchild run: the child's finished result now reaches the parent while the grandchild is still pending (main dropped it after ten deferrals). |
…livery stays pending (openclaw#165987) Deliver a finished subagent's result to its requester even while a grandchild's delivery is still pending, instead of dropping it after the settle-wake deferral limit ("requester settle wake deferred too many times"). Fixes openclaw#138632. Co-authored-by: Ayaan Zaidi <[email protected]>
…livery stays pending (#165987) Deliver a finished subagent's result to its requester even while a grandchild's delivery is still pending, instead of dropping it after the settle-wake deferral limit ("requester settle wake deferred too many times"). Fixes #138632. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit e6c5f72)
Related to #138632; fixes its exhausted-descendant-wait result loss. Native recovery from provider limits is separate.
What Problem This Solves
Fixes: finished subagent results are dropped (
requester settle wake deferred too many times) when a descendant below one of the children is still delivering its own result after about five minutes.User Impact
User impact: a requester that spawned (and usually yielded on) several subagents gets their results even when a grandchild's delivery is stuck — for example because its parent child hit a provider session limit, or is running a
sessions_sendfollow-up turn. Before, every finished child of the batch was marked failed and the requester was never woken. The forced wake tells the requester a descendant result was still undelivered and that a child may report again separately.Why This Change Was Made
deferBatchcounts a deferral towardREQUESTER_SETTLE_WAKE_MAX_DEFERRALSwhile descendants are unsettled (ended, nocleanupCompletedAt, delivery not terminal) and none is active. That state is legitimate and can outlast 10 × 30 s: a grandchild still delivering into a child whose run died on a provider limit, or into a child running a follow-up turn (not a registry run, soactive === 0). At the cap the whole batch was completed as undelivered. Now the spent wait stops waiting and dispatches the drained batch through the normal delivery path (which keeps its own attempt and replay budget); every otherdeferBatchexit is unchanged. The wake message is built after the dispatch-time descendant check so it never claims the descendant tree settled when it did not.Evidence
Production receipt on 2026.9.8 (ab2e926), persisted
subagent_runsrows, ids redacted:completionTarget: "parent"); 4 ended ok 15:32–15:37Z.You've hit your session limit; the grandchild's delivery stayed pending until 16:21:49Z.delivery.status: failed,lastError: requester settle wake deferred too many timesat 15:56:49Z; requester only noticed via a heartbeat an hour later.sessions_sendfollow-up → 2 more rows failed the same way.Tests:
subagent-announce.requester-settle-wake.test.ts: "keeps active overlap pending and stops waiting on a stale settle blocker" (was: caps → undelivered) now expects one dispatch at the cap with the unsettled-descendant wording; new "delivers a yielded batch whose grandchild delivery never settles" (frozen 2-child yield batch, unsettled + active 0 for 10 rounds → one dispatch with both children, no "settled, including its descendants"). Both fail onmain, pass here.pnpm test <file> --maxWorkers=1: 31.7 s cold / 12.0 s warm (32 tests). CI duration: unavailable.subagent-registry.requester-wake-settlement.test-support.ts(product flow, real registry, run bysubagent-registry.requester-wake.e2e.test.ts): the stale-blocker case now delivers once with the new wording instead of completing undelivered (35/35 locally). CI duration: unavailable.src/gateway/server.startup-recovery-webchat.test.ts;tsgocore +agents-sessionstest project 0 errors;oxfmt --check/oxlintclean on changed files.Real behavior proof (after fix, production)
Same 5 gateways (Linux host, npm global install, systemd units), 2026.9.8 + this PR's change as a local patch (head
07dd2d5df4backported to the dist chunk), live since 2026-10-06 09:55Z. Window 2026-10-06 09:55Z → 2026-10-07 05:30Z.Before (same gateways, unpatched, 2026-10-05 15:00Z → 2026-10-06 09:55Z, ~19 h): 14 batches / 24 child runs on 2 gateways persisted with
lastError: requester settle wake deferred too many times; every finished child marked failed, no requester wake.After:
requester settle wake stopped waiting for unsettled descendants after 10 deferrals; delivering the drained batch.deferred too many times; 0 gateway log lines with it.SESSION_WORK_START_CHANGEDon attempt 1 (requester session restarting) and went through the normal 30 s retry path, as designed: the forced batch uses the ordinary delivery budget.Subagent announce give up (expiry)when the requester itself cannot run a turn (provider weekly limit) for 30 min — separate path.Maintainer repair and isolated Gateway proof
Retain the existing spent deferral count through dispatch, known-undelivered retry, ambiguous replay, and restored wake state. Active work still blocks dispatch, but does not recharge an already spent wait. No transcript rewrites, session-custody changes, schema changes, or migrations.
The intended bug fix is to release completed results at the inactive-descendant cap, with an honest pending-descendant notice; it does not claim the descendant settled. This changes the old terminal-failure outcome introduced by #124408, while preserving active-work and cancellation gates.
On main
0e8afcde281b3a79b27f9b20d5fbca6d1689b162, a built, isolated Gateway ran parent → child → grandchild throughsessions_spawn(the normal deferredtool_callsurface). The parent yielded, the child finished, the grandchild finished after 20 seconds, and a mock provider held the child's delivery continuation for 420 seconds. Real wall time; no clock changes or injected registry/session state. At 02:40:42 UTC the parent received onlySubagent completion delivery is blocked: requester settle wake deferred too many times, without its child's finished result.On
3572962ef89c9d4e85c76f02b9037a1c9c55c703, the same flow deliveredCHILD_FINISHED_RESULT_165987to the parent at 02:56:16 UTC while the descendant continuation was still pending. The completion included the pending-descendant notice, and the parent repliedPARENT_RECEIVED_RESULT_165987.Focused regression suite: 34 passed, 6.86 seconds wrapper wall time (3.42 seconds Vitest). The two new retry/restore cases both fail against the unmodified contributor implementation: after the ordinary 30-second retry deadline, delivery remains deferred instead of succeeding. They pass with the repair. Canonical
pnpm tsgo, full build, and changed-file formatting passed. Hosted CI timing is pending. One realgpt-5-minicall with low reasoning and a 4096-token output budget returnedLIVE_GATE_165987_OKthrough the built agent CLI.No overlap with Pash/Sarah changes. Contributor credit: @Oldrich333; the linked report and contributor production receipts remain above.
Merge danger: two-way door; reverting restores the previous completion policy without a schema migration or rewriting historical sessions. Blast radius is requester completion batches whose ended descendants remain undelivered past the wait budget; incorrect retry handling could delay or duplicate their continuation.