Skip to content

[Bug] 父代理 idle 时漏掉已完成未回传的子代理报告 / Idle parent misses already-finished undelivered subagent reports #226

Description

@xingleiwu

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:

  1. Parent Tasks a short explorer. Subagent finishes in a few hundred ms (settleDelegation → status completed).
  2. Parent continues, then waitForIdle()no TaskWait.
  3. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions