Skip to content

fix(delegation): settle stopped subagents reliably - #1215

Draft
wen2zhou wants to merge 1 commit into
aipoch:mainfrom
wen2zhou:fix/subagent-termination-ui-state
Draft

fix(delegation): settle stopped subagents reliably#1215
wen2zhou wants to merge 1 commit into
aipoch:mainfrom
wen2zhou:fix/subagent-termination-ui-state

Conversation

@wen2zhou

@wen2zhou wen2zhou commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Problem

A user-reported regression caused stopped subagents to lose output that had already been produced, affected delegated ask-user cards, and allowed notebook host.stopChild to block indefinitely when provider, artifact, or lease cleanup did not settle.

Proposed change

  • Separate the cancellation action fence from the runtime observation lane. Stop blocks new continuation, permission, question-admission, and capability writes without discarding same-Attempt runtime observations.
  • Persist same-Attempt late message and tool evidence through transport shutdown, with event-id idempotency, so the evidence remains visible after reopening the Session.
  • Own transcript projection through per-Turn lanes keyed by runtime segment and prompt Message. Live observation and terminal settlement reuse one Message identity without duplicating output or attaching evidence to another Branch.
  • Keep terminal lifecycle authoritative: late evidence can extend the transcript but cannot revive or rewrite a completed, cancelled, or errored Attempt.
  • Keep a completed subagent's pending ask-user card answerable. Stop atomically cancels pending questions while transitioning only a still-running Attempt.
  • Acknowledge durable Stop independently from detached provider, artifact, backend-claim, and capacity cleanup, while preserving observable retry and exactly-once release behavior.
  • Keep cleanup reporting, detached drains, and retryable exactly-once releases behind the delegated-cleanup deep Module instead of expanding the delegated-work composer.
  • Keep durable/live transcript reconciliation behind the workspace-subagent-runtime-transcript deep Module, leaving the runtime presentation hook focused on subscription and lifecycle fencing.
  • Preserve the user-facing Cancelled label and warning-color status semantics.

Scope

  • Delegated ACP cancellation, observation, and cleanup lifecycle.
  • Per-Turn delegated transcript persistence and Session reload behavior.
  • Durable delegated-work Stop/question finalization and notebook RPC coverage.
  • Renderer subagent summary/detail terminal-state projection.
  • No documentation changes.

Acceptance

  • Cancelled, failed, and awaiting-user subagents do not retain stale Thinking state.
  • Stop fences actions without dropping same-Attempt late message or tool evidence.
  • Persisted late evidence remains visible after reopening and cannot revive terminal lifecycle state.
  • Multi-Turn Attempts retain one transcript Message identity per Turn lane without duplicate output or cross-Branch evidence.
  • A completed Attempt may retain an answerable pending ask-user card; Stop cancels that card atomically without rewriting the completed Attempt.
  • host.stopChild returns without waiting indefinitely for external cleanup.
  • Independent ownership releases remain observable, retryable, and exactly once.
  • The terminal UI label remains Cancelled.

Review focus

  • Separation of the action fence from the observation lane.
  • Per-Turn transcript lane identity, event-id idempotency, and persistence provenance.
  • Atomic question cancellation versus Attempt lifecycle transitions.
  • Separation of durable Stop acknowledgement from external cleanup drains.
  • Renderer preservation of durable output while clearing only transient runtime presentation.
  • The cleanup and renderer transcript Module seams, including their reduced composer/presentation surfaces and module-impact ownership.

Related issue

User-reported regression; no issue number.

Verification

All checks below ran after the last material edit:

  • Main Stop/persistence/architecture focused set: 5 files passed, 77 tests passed.
  • Delegation, ACP, transcript, and notebook focused set: 4 files passed, 152 tests passed.
  • session_persistence Module suite: 6 files passed, 265 tests passed.
  • Renderer architecture, HomePage, module-impact, and release surfaces: 7 files passed, 197 tests passed.
  • Module-impact validator/shadow rerun: 2 files passed, 22 tests passed.
  • npm run typecheck:node
  • npm run typecheck:web
  • ESLint on every modified/new TypeScript and TSX file.
  • Prettier check on every modified/new file.
  • Working and cached git diff --check with no whitespace errors.

The known renderer callable-surface count mismatch, stale local Prisma client failures, and Windows E2E failure were independently identified as unrelated to this PR and were not changed here.

@github-actions github-actions Bot added the bug Something isn't working label Aug 14, 2026
@wen2zhou
wen2zhou force-pushed the fix/subagent-termination-ui-state branch from 98c5a93 to 143a13c Compare August 14, 2026 12:25
@wen2zhou wen2zhou closed this Aug 14, 2026
@wen2zhou wen2zhou reopened this Aug 14, 2026
@wen2zhou
wen2zhou force-pushed the fix/subagent-termination-ui-state branch from 143a13c to 8e186f7 Compare August 14, 2026 14:01
@wen2zhou
wen2zhou marked this pull request as ready for review August 14, 2026 14:23
@wen2zhou
wen2zhou force-pushed the fix/subagent-termination-ui-state branch from 8e186f7 to 6194fcc Compare August 14, 2026 14:51
@wen2zhou
wen2zhou marked this pull request as draft August 14, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant