@@ -74,6 +74,7 @@ import {
7474import { modelSelectionsEqual } from "@t3tools/shared/model";
7575import { recordThreadOpen } from "@t3tools/shared/paletteSearch";
7676import {
77+ backgroundWorkHoldsCompletion,
7778 derivePendingBackgroundWork,
7879 pendingBackgroundTurnItems,
7980} from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
@@ -13342,14 +13343,14 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
1334213343
1334313344 // A child whose run ends while its background tasks or its own subagents still run has no
1334413345 // result yet. When that work settles there is no run update to finalize it, so these events
13345- // do it. A background roster counts once it empties after it was seen non-empty .
13346+ // do it. A background roster counts once it stops holding after it was seen holding .
1334613347 const providerThreadsWithBackgroundWork = new Set<string>();
1334713348 const settlesChildWork = (stored: OrchestrationV2StoredEvent) => {
1334813349 const { event } = stored;
1334913350 if (event.type === "subagent.updated")
1335013351 return !isOrchestrationV2WorkActive(event.payload.status);
1335113352 if (event.type !== "provider-thread.updated") return false;
13352- if ((event.payload.pendingBackgroundTasks?.length ?? 0) > 0 ) {
13353+ if (backgroundWorkHoldsCompletion (event.payload.pendingBackgroundTasks ?? []) ) {
1335313354 providerThreadsWithBackgroundWork.add(event.payload.id);
1335413355 return false;
1335513356 }
0 commit comments