Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(orchestrator): Wake idle parents for each delegated sibling #9103

Closedmwolson(GitHub profile, opens in a new tab)wants to merge 250+ commits intot3code/codex-turn-mapping fromrefs/pull/9103/headopened View on GitHub

What Changed

When several app-owned delegated children finish one after another, an idle parent now gets a wake for each result. A live parent run still queues those wakes, or folds a later sibling into a wake that is already queued, the same way a follow-up message would.

A cancelled wake still leaves its tasks pending, so Stop does not immediately start another wake. Recovery and wake-policy then reserve that pending-only cohort and offer it, so a last-child cancel does not leave the parent silent.

Why

#5311 delegated-completion-delivery capped a parent run at two wakes so a slow third child could finish with no prompt at all. Waiting is not a live turn. An idle parent should keep going, like a queued message that just became ready.

UI Changes

No layout or control changes. The parent timeline can show more than two server wake prompts for one originating run, one per finished sibling after the parent is free. No screenshots; the extra rows are the existing delegated-task wake copy.

Manual check: Pi · orchestration, scenario 2 in the provider live-test guide. On a v2.1 Nightly AppImage, three Pi children produced three wakes. The MID wake started while SLOW was still running, and each wake quoted its child token.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Remove two-delivery cap in DelegatedCompletion cohort and auto-reserve pending deliveries

  • Removes the early-return in makeOrchestrator that capped settled deliveries at 2, so late-finishing siblings each get their own delegated-completion delivery instead of staying pending
  • Adds reservePendingDelegatedCompletionDelivery, which collects terminal subagents with completionDelivery.state === 'pending', claims them, and arms the parent run with a new delivery generation — called before the offer cycle so newly reserved deliveries are visible in the same pass
  • Changes offer-eligibility from settledDeliveryCount < 2 to deliveryRun.status !== 'cancelled', preventing re-offering of cancelled delivery runs
  • Replaces the inline per-run offer loop with a single offerDelegatedCompletionDeliveries(thread.id) call
  • Behavioral Change: cohorts can now produce more than two delivery generations; existing tests in OrchestratorMcpToolkit.integration.test.ts were updated to expect 3 deliveries, and a new test in DelegatedCompletionDelivery.test.ts covers re-planning after a cancelled wake
Macroscope summarized 4978994.

Note

Medium Risk Changes core v2 delegated-completion scheduling and parent wake ordering; behavior is heavily tested but affects multi-child delegation and cancel/recovery paths.

Overview Removes the per–parent-run limit of two delegated-completion wakes so each terminal sibling can eventually get its own follow-up once the parent is idle, instead of staying stuck in pending after the second delivery.

Orchestrator drops the settledDeliveryCount >= 2 early exit when planning new deliveries and changes follow-up reservation to require a non-cancelled delivery run (not a delivery count). It adds reservePendingDelegatedCompletionDelivery, which batches terminal tasks still in pending into a new cohort delivery and marks them claimed, and offerDelegatedCompletionDeliveries now reserves pending cohorts before offering. Recovery after terminal delivery runs routes through that unified offer path.

Tests extend the MCP late-parent scenario for a third sibling wake (settledDeliveryCount 3, three continuation offers) and add a unit test that a cancelled wake leaves the task pending, then wake-policy / replan restores claimed delivery on the parent.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 4978994a83333249fbfc60b5b4d0dffcf01acd28. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This production change alters when delegated task completions trigger additional parent model runs, removing the prior two-wake limit and adding cancellation recovery. Because it changes significant existing-path processing and user-visible orchestration behavior, human review is warranted despite focused test coverage.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.

      Fix All in Cursor ❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the [Cursor dashboard](https://www.cursor.com/dashboard/bugbot). Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 6e3354608f8609be8d939b435cff93e2844b0be6. Configure [here](https://www.cursor.com/dashboard/bugbot).
    4. juliusmarminge closed this

    5. Closing as part of the open-PR backlog sweep (wave 2).

      Reason: Contaminated 955-file/192k conflicting rebuild; title-sized change is unrecoverable as-is

      Reopen if this is still wanted and you’re willing to rebase onto current main.

Sign in to join this conversation.