Problem / 问题
If the parent goes idle after a same-turn subagent has already finished, but before resumeAfterDelegations (or TaskWait) delivers the report, the report is dropped.
D328 is supposed to keep the parent turn open and auto-feed delegate reports. Stock 0.14.6 only loops while running delegations exist:
private async resumeAfterDelegations(): Promise<void> {
while (
!this.disposed &&
!this.runCancelled &&
this.runningDelegations().length > 0
) {
const targets = this.runningDelegations();
await this.waitForDelegations(targets, targets.length, null);
// ... prompt the parent with settled reports ...
}
}
Race:
- Parent
Tasks a short explorer. Subagent finishes in a few hundred ms (settleDelegation → status completed).
- Parent continues, then
waitForIdle() — no TaskWait.
resumeAfterDelegations(): runningDelegations() is empty → return. Report never injected.
The TaskWait description says unfinished delegates keep working and the runtime will deliver reports when they finish. Fast-finished ones that settled before the parent idled are not “unfinished”; they are already done and still unpublished.
父代理 idle 前子代理已经跑完、报告还没回传时,自动回传条件只看「还在 running」,会漏掉。
Proposed change / 期望改动
Treat “current-turn, not yet delivered” as the wait set, not “currently running”:
pendingCurrentTurnDelegations(): same turnEpoch, !reportDelivered, not aborted/stopped.
- Keep the turn open if running or pending-undelivered (
keepTurnOpenForDelegates).
resumeAfterDelegations: loop while pending-undelivered length > 0; wait; inject only settled records that are still !reportDelivered; mark delivered once.
- Do not mark still-
running records as delivered (TaskWait timeout / any must not consume a future auto-resume).
- Stop / abort / parent fatal error: do not auto-prompt leftover reports.
Auto-delivery is a single shot per record (reportDelivered). TaskWait that already returned a completed report should set the flag so resume does not duplicate it.
Alternatives / 其他方案
- Require the parent to always
TaskWait: the product already promises auto-delivery on idle (D328); models often skip Wait when the worker looks instant.
- Leave completed reports only in the UI card: the parent model never sees them and continues as if the delegate produced nothing.
Additional context / 补充信息
PI-Desktop 0.14.6. packages/agent-runtime resumeAfterDelegations / TaskWait / D328.
Related: #215 (subagent tool inherit) is about what delegates can call. This issue is about whether the parent ever sees the report.
Problem / 问题
If the parent goes idle after a same-turn subagent has already finished, but before
resumeAfterDelegations(orTaskWait) delivers the report, the report is dropped.D328 is supposed to keep the parent turn open and auto-feed delegate reports. Stock 0.14.6 only loops while running delegations exist:
Race:
Tasks a short explorer. Subagent finishes in a few hundred ms (settleDelegation→ statuscompleted).waitForIdle()— no TaskWait.resumeAfterDelegations():runningDelegations()is empty → return. Report never injected.The TaskWait description says unfinished delegates keep working and the runtime will deliver reports when they finish. Fast-finished ones that settled before the parent idled are not “unfinished”; they are already done and still unpublished.
父代理 idle 前子代理已经跑完、报告还没回传时,自动回传条件只看「还在 running」,会漏掉。
Proposed change / 期望改动
Treat “current-turn, not yet delivered” as the wait set, not “currently running”:
pendingCurrentTurnDelegations(): sameturnEpoch,!reportDelivered, not aborted/stopped.keepTurnOpenForDelegates).resumeAfterDelegations: loop while pending-undelivered length > 0; wait; inject only settled records that are still!reportDelivered; mark delivered once.runningrecords as delivered (TaskWait timeout /anymust not consume a future auto-resume).Auto-delivery is a single shot per record (
reportDelivered). TaskWait that already returned a completed report should set the flag so resume does not duplicate it.Alternatives / 其他方案
TaskWait: the product already promises auto-delivery on idle (D328); models often skip Wait when the worker looks instant.Additional context / 补充信息
PI-Desktop 0.14.6.
packages/agent-runtimeresumeAfterDelegations/TaskWait/ D328.Related: #215 (subagent tool inherit) is about what delegates can call. This issue is about whether the parent ever sees the report.