Repository navigation
test(agents): inline child follow-up cases fail intermittently when the registry wait lands during teardown - #183244
Conversation
The inline child follow-up fixture answered every agent.wait for the child run, including the registry's own background completion wait. That wait holds no Gateway root work while pending, so under CI load its completion (and, in the ok case, a second lifecycle end) could land after the test settled and race resetSubagentRegistryForTests deleting the row. The rejected root then failed the case with "Subagent terminal execution changed" or "Subagent lifecycle event lost its original run". Hold the registry wait on a deferred: error and timeout release it after the inline result is consumed and wait for cleanup, so the registry's observation is still exercised deterministically; ok releases it after teardown because its lifecycle event already ended the child.
|
🦞👀 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 SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR controls the registry’s background wait separately from the inline requester wait in child follow-up tests. Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR makes a demonstrated fixture race deterministic while preserving the cleanup regression coverage; no actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe sessions-send coordination suite exercises native child completion through real registry and persistence owners with mocked Gateway responses, checking inline results, cleanup, and requester delivery. flowchart TD
A[Coordination test] --> B[Sessions send tool]
B --> C[Inline requester wait]
B --> D[Subagent registry]
D --> E[Background completion wait]
A --> F[Deferred Gateway fixture]
C --> F
E --> F
D --> G[Cleanup and delivery assertions]
Technical reviewBest possible solution: Keep the existing fixture and registry owners, explicitly order their waits, and retain cleanup assertions for all three terminal outcomes. Do we have a high-confidence way to reproduce the issue? Source confirms that the original fixture answers both waits and can emit duplicate lifecycle endings; the author reports reproducing teardown failures with injected delays, but this read-only review ran no tests. Is this the best way to solve the issue? The patch fixes the fixture’s uncontrolled completion producer using the deferred pattern already present in sibling cases, preserving the original success regression and strengthening error and timeout cleanup coverage. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 5d204234f2d2. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +18. Total +18 across 1 file. Added test files: 0. View PR surface stats
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 Reviewed October 25, 2026, 12:39 AM ET / 04:39 UTC. |
|
Merged via squash.
|
…openclaw#183244) The inline child follow-up fixture answered every agent.wait for the child run, including the registry's own background completion wait. That wait holds no Gateway root work while pending, so under CI load its completion (and, in the ok case, a second lifecycle end) could land after the test settled and race resetSubagentRegistryForTests deleting the row. The rejected root then failed the case with "Subagent terminal execution changed" or "Subagent lifecycle event lost its original run". Hold the registry wait on a deferred: error and timeout release it after the inline result is consumed and wait for cleanup, so the registry's observation is still exercised deterministically; ok releases it after teardown because its lifecycle event already ended the child.
What Problem This Solves
Fixes: the inline child follow-up cases in
openclaw-tools.sessions-send-child-coordination.test.tsfail intermittently in the Linux Bun shardcore-runtime-infra-storage-state-hosted-10when the runner is loaded. This blocked #183052 twice:(timeout)failed withSubagent terminal execution changed, then(ok)failed withSubagent lifecycle event lost its original run.User Impact
No user-visible change; this is a test-only change. CI stops failing these cases at random, and the cases now deterministically cover the registry seeing a child's ending after the requester has already consumed the result inline.
Why This Change Was Made
The fixture's
agent.waitmock answered every wait for the child run. That included the registry's own background completion wait, which holds no Gateway root work while its RPC is pending. In theokcase the mock also wrote the final reply again and emitted a second lifecycle end for that call. Under load, that second observation could land after the test'ssettleSessionWork()returned. It then racedresetSubagentRegistryForTests(), which deletes the row. The in-flight completion or lifecycle listener rejected its root, andobserveRootWorkreported that rejection as a test failure.Production already tolerates this ordering:
waitForSubagentCompletionandcompleteSubagentRunWithRecoveryreturn quietly once their owner is gone. So the fix is in the fixture, using the pattern the queued-followup cases in this file already use. The registry wait (any wait whosetimeoutMsis not the inline1000) is held on a deferred:errorandtimeout: the wait is released after the inline result is consumed, and the test waits forcleanupCompletedAtbefore settling. The registry's own observation is still exercised, now in a fixed order.ok: the lifecycle event already ended the child, so the redundant wait is released after teardown, where it finds no row and returns.#183052 is unrelated. Its production code was identical between the passing and failing heads; the extra load in the shard only widened the timing window.
Evidence
waitForAgentRun, listener after terminal observation). With the original fixture that reproduced 7/45 and 8/45 failures under Bun. Instrumentation showed the row deleted by the reset'spublishRows, and thesubagent-waitcompletion starting after the test had settled.errorandtimeoutcase completed exactly once throughsubagent-wait;okcompleted throughlifecycle-completed-event.oxfmtand the type-aware oxlint core shard pass. Codex autoreview (P2) came back scoped-clean.