Skip to content

fix(server): delegated background follow-up results do not reach the parent #476

Closed

Description

@lastobelus

After a delegated child reports its original result, a provider background command can finish and start another child run. LastCode does not register that notification-driven run as a follow-up task, so the parent does not receive its eventual result.

Confirmed source at c909106a31be7aa452a31fce86bd32d47716fadb:

  • apps/server/src/orchestration-v2/Orchestrator.ts:8313 (recordSubagentFollowup) returns for every command.notification, including background command completion.
  • The dispatch path at line 15006 locks the parent only for user/MCP messages, so simply removing the early return would leave parent writes without the matching parent lock.
  • Upstream 0504c99205e427ed1a6a571b2d4c4ece910a8a65 fixes both decisions with one predicate: provider wakes qualify, monitor progress does not (upstream change).

Deterministic reproduction for the repair:

  1. Seed an app-owned delegated child whose original completion has already been delivered/acknowledged.
  2. Dispatch a new child message with createdBy: "agent", creationSource: "provider", and notification.source.kind: "command", matching a completed background command.
  3. Inspect the new child run: it lacks a delegatedTaskId because follow-up registration returned early. Finish that run and check the parent: no new follow-up result/wake is owed.

Expected: the new child run has a follow-up task and its completion reaches the parent exactly once. Monitor notifications must not create follow-up tasks.

Adapt upstream registration and locking together, retaining LastCode family lifecycle admission, ownership-release, Pause and completion-delivery rules. The upstream regression is delivers the run a background command's wake starts after the original result in DelegatedCompletionDelivery.test.ts; extend it with paused and ownership-released cases where appropriate.

This research confirms the source defect and upstream test/fix correspondence; no tests or installed-runtime reproduction were executed here.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions