Skip to content

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

Open
mwolson wants to merge 331 commits into
pingdotgg:t3code/codex-turn-mappingfrom
mwolson:fix/delegated-completion-idle-wake
Open

fix(orchestrator): Wake idle parents for each delegated sibling#9103
mwolson wants to merge 331 commits into
pingdotgg:t3code/codex-turn-mappingfrom
mwolson:fix/delegated-completion-idle-wake

Conversation

@mwolson

@mwolson mwolson commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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 for commit 4978994. Bugbot is set up for automated code reviews on this repo. Configure here.

mwolson and others added 30 commits August 31, 2026 21:32
…y for resume, wake, and idle release (pingdotgg#3860)

Co-authored-by: Julius Marminge <julius0216@outlook.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Fixes review: pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Fixes review: pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Fixes review: pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Fixes review: pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Fixes review: pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Fixes review: pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Clears the timed-out turn with an identity guard so a late completion cannot clobber a newer active turn.

Addresses pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Passes the current target thread MCP configuration through ACP load, resume, and fork requests instead of reusing the credentials captured when the provider process opened.

Addresses pingdotgg#2829 (comment)

Co-authored-by: codex <codex@users.noreply.github.com>
Integrate the current Grok settlement, monitor/subagent lifecycle, interrupt containment, steer visibility, and image support stack into the orchestration-v2 branch.

Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Settle root turns from provider signals and preserve post-settle continuations.

Track asynchronous subagent and monitor work, allow image prompts, and keep steered messages visible.

Separate soft steering from hard Stop while containing and reaping native process trees.
Co-authored-by: codex <codex@users.noreply.github.com>
Reuses the focused compatibility approach from closed PR pingdotgg#3923 and covers the remaining hardware-keyboard reverse iteration.

Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
- Pretty-print known T3 MCP tool names in work rows
- Show the T3 Code logo for recognized MCP tool entries
- Add logic and UI tests for the new tool presentation
- Extract shared T3 MCP tool label resolution
- Show T3 Code branding for matched tool activity rows
- Add tests for shared resolution and mobile feed output
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
Co-authored-by: codex <codex@users.noreply.github.com>
juliusmarminge and others added 13 commits August 31, 2026 21:33
Adapt grouped tool summaries and the floating working timer to V2 run, attempt, and queue state. Bring over the composer, keyboard, and disclosure transitions while retaining the V2 activity inspector and queue controls.

Keep OV2 web composer and grouping behavior intact; share only the existing command label parser with mobile.
Restores main features dropped by the policy replay: pingdotgg#8569 theme wiring,
pingdotgg#8850 composer banner follow-ups, pingdotgg#8855/pingdotgg#8904 composer fixes, pingdotgg#8831
settings search rework, pingdotgg#8803 workspace-mutation refresh (v2-adapted),
pingdotgg#8840 circle-alert, pingdotgg#8584 codex artifact templates, pingdotgg#8688/pingdotgg#8807/pingdotgg#8936
video + image previews (web and mobile, v2-adapted), pingdotgg#8862 Expo glass,
and the round's docs. Timeline thinking rows (pingdotgg#8984) stay on the v2
work-live system.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The v2 equivalents of main's pingdotgg#8984 and pingdotgg#8922: a "Working for ..." header
anchors the active run, the trailing live tool row survives between
actions in past tense instead of vanishing, and a shimmering Thinking
row marks reasoning gaps. During workspace preparation the header shows
"Setting up worktree..." (driven by the local dispatch flag or the v2
run's preparing status, so remote viewers see it too), the composer
footer span is gone, and draft promotion waits until the run starts or
startup fails instead of navigating mid-preparation.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
pingdotgg#5311 capped a parent run at two completion wakes, so a later sibling
that finished after both wakes settled never prompted the parent. Offer
each follow-up as soon as the parent is free. queue_after_active still
queues behind a live run. A cancelled wake stays pending for retry
instead of immediately reserving another delivery.
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Sep 1, 2026
@mwolson
mwolson marked this pull request as ready for review September 1, 2026 21:25
Comment thread apps/server/src/orchestration-v2/Orchestrator.ts
@macroscopeapp

macroscopeapp Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

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.

Cancel still leaves claimed tasks pending so Stop does not immediately
start another wake. Recovery and wake-policy then reserve a pending-only
cohort and offer it, so a last-child cancel does not strand the result.
@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:S 10-29 changed lines (additions + deletions). labels Sep 1, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Reviewed by Cursor Bugbot for commit 6e33546. Configure here.

Comment thread apps/server/src/orchestration-v2/Orchestrator.ts
wake-policy rejects an unchanged completionWake, so the previous always
dispatch never reached offerDelegatedCompletionDeliveries. Switch always
to settled_only after cancel, and format the test file.
@juliusmarminge
juliusmarminge force-pushed the t3code/codex-turn-mapping branch 7 times, most recently from b82facd to 2ac9bfe Compare September 5, 2026 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants