Description
Summary
A parent spawned three child threads with bb thread spawn --parent-self. Two children woke the parent with a child-completed notice. The third ended while the parent's turn was about to finish, and its notice never arrived: no client/turn/requested was written, nothing was queued, and nothing was logged. I expected every child that ends to wake its parent, either right away or once the parent is idle.
Versions and environment
- bb 0.47.1, npm install (
bb-app), Node 24.22.1, Linux 6.18 (NixOS 26.11) - Parent and children on
claude-code, Claude Code 2.1.310 - Children in one worktree environment; parent
parentNotifications: autoon every child - The server was under load at the time: frequent
Event loop stalledreports (max delay 0.5 to 1.7 s)
Steps to reproduce
I could not reproduce this on demand; the loss depends on timing. Below is the closest faithful repro. It is unverified, because I have not run it.
- Start a parent thread on any provider. Have it spawn two children with
bb thread spawn --parent-self, where child A ends about 5 s before child B. A child prompt likeRun "sleep 20", then reply only with ok.gives that control. - Instruct the parent so that each
child-completednotice starts a turn that lasts about 3 to 4 s, for examplerun "sleep 3", then reply ok. - Child B then ends while the turn that A's notice started is still running. That turn ends shortly after B's 2 s batch flush.
- Check
bb thread log <parent> --jsonfor aclient/turn/requestednaming B.
This is more likely on a loaded server or with many skills installed (see "Suspected cause"). A deterministic repro would be a server test that delays prepareTurnSubmitCommandPayload in queueActiveParentSystemMessage, and ends the parent's active turn during that delay.
Expected vs actual
parent thr_8bevt3uhsz, children thr_7mhvqrz4n3, thr_ydvkra8ggs, thr_zuz47nertm (local times)
21:23:20.273 thr_7mhvqrz4n3 turn/completed
21:23:27.415 parent client/turn/requested systemMessageKind=child-completed (subject thr_7mhvqrz4n3) seq 567
21:23:27.459 parent turn/started
21:23:28.443 thr_ydvkra8ggs turn/completed (its only turn)
21:23:31.060 parent turn/completed seq 580
21:23:50.305 thr_zuz47nertm turn/completed
21:24:04.481 parent client/turn/requested systemMessageKind=child-completed (subject thr_zuz47nertm) seq 582
Expected: a `client/turn/requested` for `thr_ydvkra8ggs`, either steered into the running turn or queued until the parent is idle.
Actual: none. The parent's event sequence from 563 to 592 has no gaps, so no event was written and pruned later. The DB has no `queued_thread_messages` row for the parent, and the server logged nothing for it.
Evidence
Observed: two code paths drop the notice. Code links are permalinks at the desktop-v0.47.1 tag (5e1acd7). parent-system-messages.ts and child-thread-notifications.ts are byte-identical on main at 9eb0c09.
flushChildThreadTurnNotificationBatch (child-thread-notifications.ts#L389-L420) deletes the batch first. It ignores a false return from queueParentSystemMessage and logs and drops a throw, so nothing retries or queues the notice. queueParentSystemMessage reads the parent's status once, awaits the turn preparation, and only then rechecks the status inside the write transaction.
- Silent drop. The parent is
activewhen the notice is prepared but idle by the transaction.queueActiveParentSystemMessageawaitsprepareTurnSubmitCommandPayload(L305). ThenqueueActiveParentSystemMessageInTransactionseescurrentThread.status !== "active"and returnsnull(L223-L235), and the caller returnsfalse(L330-L331). This is thethr_ydvkra8ggscase:- its batch flushed at about 21:23:30.4, when the parent was
activein turn t13; - t13 ended at 21:23:31.06, before the transaction ran;
- the server logged
Event loop stalledwithmaxDelayMs: 1718at 21:23:30.398.
- its batch flushed at about 21:23:30.4, when the parent was
- Logged drop. The parent is idle when the notice is prepared, but a turn has started by the transaction, usually from a sibling's notice.
queueReadyParentSystemMessageawaitsprepareReadyThreadTurnCommand(L367). Thenrun.startedfromactivethrows inside the transaction (L386-L399). The rollback removes theclient/turn/requestedthe transaction had just appended. The error is not one of the two thatqueueParentSystemMessageturns into a queued message (L458-L462). Example from the same parent:thr_dpqj7vdnvwended at 21:15:32 with the parent idle;- a parent turn started 3.1 s later;
- then:
21:16:11.745 Failed to queue batched parent turn notifications parentThreadId=thr_8bevt3uhsz childThreads=[thr_dpqj7vdnvw completed] ThreadLifecycleEventNotAppliedError: Thread lifecycle event not applied (illegal-transition): no transition for run.started from status active at requireThreadLifecycleEventApplied at deps.db.transaction.behavior (inside queueReadyParentSystemMessage)
Counts. I took a read-only copy of the local DB and counted children with parent_notifications=auto and no origin_kind. A loss is a root turn/completed with status completed and no system client/turn/requested naming that child within 10 minutes. Versions are assigned by when each ran on this install, taken from the version in server log paths.
| Version | Child completions | Lost | Median / p90 child end to notice |
|---|---|---|---|
| 0.46.1 (5 days) | 1554 | 3 (cause unknown; that parent is now archived) | 2.0 s / 2.2 s |
| 0.47.0 (12 h) | 184 | 0 | 2.0 s / 2.5 s |
| 0.47.1 (7.5 h) | 457 | 17 | 4.0 s / 11.3 s |
Each 0.47.1 loss fits one of the two paths by timing:
- 10 silent (path 1): the parent was active, and its turn ended 2.6 to 4.4 s after the child ended, just past the 2 s batch flush.
- 7 logged (path 2): the parent was idle, and a parent turn started 2.6 to 19 s after the child ended. Each matches a
Failed to queue batched parent turn notificationsline.
That log message appears 9 times under 0.47.1 and in none of the 0.46.1 or 0.47.0 server logs still on disk. Event loop stalled reports per hour of log rose from about 5 (0.46.1) and about 8 (0.47.0) to about 80 (0.47.1).
Suspected cause of the jump in 0.47.1 (medium to high confidence, not measured per span). The two drop paths are the same code in 0.46.1, 0.47.0 and 0.47.1, so the race is old. What changed is the time between the two status checks.
In 0.47.1, resolveThreadRuntimeCommandConfig, which builds every turn dispatch including parent notices, now awaits skill discovery:
scanSkillFiles awaits one fs.stat and one fs.readFile per SKILL.md, in sequence. Each await yields to the event loop, and with the loop stalling, preparation now takes seconds. During that time other daemon event posts are applied, including the parent's own turn/completed or turn/started.
What supports this:
- It is the only change between 0.47.0 and 0.47.1 on the code path between the two checks.
- Latency and losses jump at the upgrade.
What I did not establish:
- The time spent in each span. Turn-trace spans
runtimeConfig.pluginConfigtoruntimeConfig.builtfor parent notices would settle it. - Whether other load, such as a third-party plugin's RPCs that dominate
inFlightWorkAtObservation, adds to the stalls.
What you ruled out
- Not Queued messages dropped under rapid back-to-back sends: ThreadLifecycleEventNotAppliedError (no transition for run.started from status active) #3716. It is the same
run.started from status activerace, but on the userthreads.sendpath. Its fix (Recheck thread status before committing dispatch #3718) did not touchparent-system-messages.ts, which still has both paths onmainat9eb0c09. - Not A parent should only get a turn end notice for a turn it started #5560, Let a child thread tell its parent only when it finishes, not after every turn #4487 or Control how often a child thread wakes its parent: every N turns or after an idle interval #5831. Those ask to change when a parent should be notified; here a notice bb meant to send is lost.
- Not the per-parent 2 s batch merging notices: the lost child's ID appears in no later notice, single or batch.
- Not
parentNotificationsstuck/off: all children areauto,originKindnull. - Not the environment-directory continuation that defers a parent notice: the lost child's turn has no
system/operationevent. - Not a pending user interaction: that case queues the notice and delivers it later. Nine such delayed notices on another parent all arrived, and I excluded them from the counts.
- Not event pruning: the parent's event sequence around the loss has no gaps.
Suggested priority and effort (optional)
No response
Checks
- I reproduced this on the latest release or on
main, or I say above that I could not. - I searched open and closed issues for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATEDand links the thread or report.
Activity
bb-slop-cop commentedon Oct 24, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotthreads.confirmed-repro. Both races repeat in a second clean trusted checkout.Retry parent notices after dispatch status changes (get-bb#6243)