Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): avoid completion alerts before delegated work resumes #31357

MergedAkiVonAkira(GitHub profile, opens in a new tab)merged 17 commits intomain fromrefs/pull/31357/headmerged by juliusmarminge View on GitHub

Problem

The completion sound can fire when a delegated child finishes, before the parent resumes to process its result. The parent shell reads as done during two gaps:

  • Before the wake run exists. The child's result commits before the continuation worker creates the parent's wake run.
  • Between deliveries. A delivery run's completion commits before the next delivery claims a sibling that finished meanwhile.

In both gaps the parent has a completed run and an empty background roster, so clients play the completion alert.

Closes #31346. Related to the previously triaged #13625.

Change

One branch of the shell's pending-work query keeps a finished app-owned task in the parent's roster as waiting. It applies while the task's completion delivery is claimed or pending, its cohort is open, a delivery is reserved, and its run is not rolled back. While the wake run is queued or active, the existing roster gate takes over.

The hold releases at these points:

  • The wake run ends and moves the task to delivered.
  • A steered wake is accepted.
  • The provider instance is disabled, and the worker acknowledges the task.
  • The cohort is stopped or disposed.

The held row has no owning provider instance. It holds the completion alert but does not count as a live MCP caller, so the parent_not_active guard on an ended parent still applies. Persisted task status, contracts, and settings stay unchanged.

Tests

Both regression tests are in DelegatedCompletionDelivery.test.ts, and each failing test was committed before its fix.

  • Lifecycle test. It drives two children through the orchestrator. It checks the hold before each wake is dispatched, including when the spawning run already has a newer run. It also checks the release after each wake run completes.
  • Seeded test. It seeds the state between a delivery run's end and the next claim, and checks the hold. A second row with no reserved delivery checks that a pending task does not hold the parent forever. A third row checks that a task from a rolled-back run does not hold the parent after a later run settles.

Scope and approval

This is a small, focused correction to existing completion behavior under the obvious-bug exception in CONTRIBUTING.md. It changes one shell query and its regression tests. It introduces no setting, contract, or workflow.

The fix covers T3-owned delegated completion delivery. Provider-native Monitor behavior is outside this change.

Verification

On main, both tests fail:

  • Lifecycle: expected [ 'thread:wake-handoff-second' ] to deeply equal [ 'thread:wake-handoff-first', 'thread:wake-handoff-second' ].
  • Seeded: expected [] to deeply equal [ 'subagent' ].

The earlier versions of this branch each miss one case. With the reserved-delivery condition removed, the unreserved row fails. Without the rollback condition, the rolled-back row fails with expected [ 'subagent' ] to deeply equal [].

After rebasing onto main at 6417151c09, 2750 tests pass across src/orchestration-v2, src/mcp, src/peer, and src/relay. That includes RemoteDelegation.test.ts, which checks caller access and message read counts. 9 tests in ProviderTurnStartService, AntigravityAdapterV2, OpenCode2AdapterV2, and ClaudeReplayFixtures fail on this Windows machine with or without the change, and CI passes them. vp run check:changed passes.

Native Windows sound playback and a running-client reproduction remain unverified. No client code changed.

Council review

Rounds: 2

DelegateRound 1Round 2
Claude Opus (SQL shape)7/108/10
Claude Opus (write side)8/108/10
Claude Opus (read placement)8/109/10
Claude Opus (tests)7/108/10
GPT Sol (SQL shape)8/109/10
GPT Sol (write side)9/109/10
GPT Sol (read placement)9/109/10
GPT Sol (tests)8/109/10

Reviewed with sol-loop: 3 rounds with GPT-6.1 Sol on medium. Sol verdict: approved.

Created with Claude Opus 5.5 in Claude Agent, through T3 Code. Reviewed and filed with GPT-6.1 Sol in Codex, through T3 Code.

    1. Pushed7bf611f

    2. Evidence

      Windows Server 2025 Electron, light theme, 1100×780 renderer, fresh isolated server databases and client profiles, real OpenCode 1.19.6 / GPT-6.1 Sol.

      Enabled notification sounds, launched two asynchronous T3 delegates with 20- and 35-second shell waits, ended the parent's initial turn, and let the parent spend 30 seconds processing each automatically delivered result. The second child finished while the parent processed the first result. The labelled capture overlay observes actual Web Audio starts; the recordings contain the actual emitted audio.

      BeforeAfter
      f03c315a3e7bf611f3fa
      Before: sound already emitted while final follow-up runsAfter: no sound while final follow-up runs
      Windows recording — early sound around 2:10, then final soundWindows recording — one final sound around 2:35

      Frames above are extracted from the recordings. Base emitted its first sound at 18:36:23.722, before the final follow-up started at 18:36:24.958; that follow-up completed at 18:37:04.305. Head emitted no handoff alert and sounded once at 18:37:25.278, after final completion at 18:37:24.043. See the base runtime milestones and head runtime milestones.

      Reproduction files: Windows seed/driver, Electron capture driver, audio observer, video encoder. Raw native captures: base, head.

      Single-delegate corroboration: Windows before, Windows after. The single-delegate after export ends at sound onset and has a short audio tail; the primary two-delegate recordings retain the final alert.

      The web client independently reproduced the difference with the same two-delegate prompt: before, after.

      Not shown:

      • Unreserved results and rolled-back source runs were not exercised; the captured flows use reserved deliveries and successful runs.
      • Failed, interrupted, and cancelled child outcomes were not exercised; all captured children completed successfully.
    3. juliusmarminge added labelstakeover:ready

    4. juliusmarminge removed labelstakeover:in-progress

    5. juliusmarminge merged thisc1ae0e9

    6. juliusmarminge closed this

    7. juliusmarminge removed labelstakeover:ready

Sign in to join this conversation.