Skip to content

fix(delegation): show per-subagent completion and restore reliable Main wakes - #3207

Draft
wen2zhou wants to merge 7 commits into
aipoch:mainfrom
wen2zhou:fix/settlement-wake
Draft

wen2zhou wants to merge 7 commits into
aipoch:mainfrom
wen2zhou:fix/settlement-wake

Conversation

@wen2zhou

@wen2zhou wen2zhou commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Subagent completion has two distinct user-visible paths. A Main turn blocked in host.delegate(..., { wait: true }) remains active until all children finish, so the existing idle-settlement wake does not show each completion. The reported three-child OpenCode run followed that path and eventually persisted its final summary, but had no intermediate completion notices.

Idle settlement also regressed after Main-owned durable admission was introduced. The original continuation lacked an admissible execution and independent usage identity. Review found two further missed cases: a retired runtime could consume an unsent notification, and a fast sendMessage followup could finish before Main released its turn without being watched.

Changes

  • Show one durable completion, failure, or cancellation row per direct-child Attempt in Main’s active conversation branch, including while Main is waiting. Each row opens the existing Subagent preview; rows survive restart and remain deduplicated across followups. This does not start an extra model request or interrupt the active Main turn.
  • Restore idle settlement through the existing Main admission, dispatch fence, retry, and terminal owners. Scope each continuation’s Segment and model-call usage independently, preserving earlier answers and artifacts.
  • Restore retired Sessions using their saved framework/provider/model and continuity information under the same deletion guard and root admission as dispatch. Preserve the history-replay requirement across proven pre-provider failures; Stop and branch changes invalidate pending work.
  • Track newly created followup Attempts and suppress already collected or duplicate receipts.
  • Add privacy-safe error categories for failed preparation while retaining no-replay behavior after possible provider dispatch. Include all eight renderer translations and module ownership/consumer registration.

This continues PR #3207 and incorporates current main, including terminal-persistence recovery and turn outcomes. It does not replace the delegation architecture, change wait:true semantics, or add a notification database.

Validation

Final candidate: 1cdab8c25809b815c9b6125df076e4ae307e1ff6.

  • Electron: 40 passed, 2 skipped, 0 failed across Subagent release, delegation resume/cold recovery, interaction restart, interrupted-turn recovery, background-result delivery and Artifact/Task lifecycle. The skips require unavailable OPEN_SCIENCE_E2E_PYTHON and COMPUTE_TEST_SSH_ALIAS. This ran on the final production tree; the final commit only adds the new composition test to six architecture inventory assertions.
  • Focused runtime/workflow/production-composition and consumer coverage: 760 passed; settlement dispatch/persistence: 135 passed; final architecture project: 219 passed across 33 files.
  • Full repository run before the final inventory correction: 48,891 passed, 11 failed, 846 skipped. Six failures were exact architecture inventories corrected in the final commit and covered by the passing complete architecture rerun. The other four affected files were rerun with one worker: 269 passed, 1 failed. The remaining failure is the baseline macOS path assertion below; the earlier process-result and export-validation failures did not reproduce in that rerun. The full-suite invocation itself is not reported as green.
  • Complete Node/sandbox and renderer type checks, Electron build, changed-file Prettier and diff checks passed. Full lint passed on the reviewed snapshot, with affected-source lint repeated after final fixes. Module ownership audit passed: 6,184/6,184 files, 148 modules.

The remaining local failure was independently reproduced on unmodified main 5609e9f07: shell-npm-environment.test.ts / shares win32 global tools across launches while keeping them outside disposable cache compares /var with its canonical /private/var path on macOS. No timeout, skip or assertion was relaxed. The final-head GitHub PR Gate is running; CI Integrity has passed.

Electron uses a deterministic OpenCode fixture for the provider and exercises real Host RPC, persistence, runtime admission and renderer. The new three-child case releases each child independently, checks that notices appear while Main stays active, verifies no extra Main prompt, then verifies the same Attempt rows after restart. Neighboring recovery, permission, reliable-message, background-result and Artifact/Task journeys are included.

Review

Six sequential pr-review-toolkit passes cover correctness, tests, error handling, comments, types and simplification. The review findings were fixed and independently re-reviewed: retain cold-restore context across retries and consume it only on current provider evidence; reject array-valued persisted enums; preserve safe diagnostic categories; correct a misplaced sanitizer comment. Production restoration wiring now has direct coverage. No high-confidence findings remain; the simplification pass recommended no architectural rewrite.

Admit frozen settlement batches through Main-owned durable witnesses and independent execution segments. Fence provider dispatch and preserve proven pre-dispatch cleanup retries without replaying uncertain executions.
@github-actions github-actions Bot added bug Something isn't working size:XXL 1000+ added/deleted lines, excluding lockfiles labels Oct 1, 2026
Reuse durable scope construction and identical phase checks. Preserve settlement scenarios, assertions and dispatch boundaries while sharing local test setup.
@wen2zhou wen2zhou changed the title fix(delegation): restore settlement wakes after main completes fix(delegation): show per-subagent completion and restore reliable Main wakes Oct 2, 2026
@wen2zhou
wen2zhou force-pushed the fix/settlement-wake branch from 2c74b1c to 367c1f4 Compare October 2, 2026 17:19

This branch has not been deployed

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

Labels

bug Something isn't working size:XXL 1000+ added/deleted lines, excluding lockfiles

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant