Skip to content

fix(subagents): harden lifecycle, completion delivery, and transcript UX across the stack - #347

Closed
Rinat S (rsolmano) wants to merge 6 commits into
mainfrom
subagents-hardening
Closed

fix(subagents): harden lifecycle, completion delivery, and transcript UX across the stack#347
Rinat S (rsolmano) wants to merge 6 commits into
mainfrom
subagents-hardening

Conversation

@rsolmano

Copy link
Copy Markdown
Collaborator

Summary

Post-merge hardening for the subagents stack (#302/#303/#304), from a full-feature review with adversarial verification of every finding. Fixes the still-open #303 review thread (child settings parity) plus confirmed defects across all three layers: lost aborts, silently-dropped background completions, false-permanent transcript errors, an unrestricted-tools parsing hole, and missing regression pins.

Changes

packages/pi-delegation

  • An abort landing in pi prompt() preflight (before streaming starts) is now re-delivered from the run's event subscription — previously the child streamed to full completion, billed, returned as aborted with the completed finalText, and delete/archive flows blocked on the whole natural run.
  • finalText derives from the run's own turn_end-captured assistant message (index-scan fallback retained) — a mid-run compaction no longer misreads a completed run as "(no output)".
  • steer() rejects with typed not-running unless a run is queued/running; aborted-before-start runs clear the pi queue, so a stale steer can no longer contaminate the child's next run.
  • Lifecycle listeners and onUpdate callbacks are exception-isolated — a throwing embedder callback can no longer reject a completing run or abandon a disposal cascade.
  • onUpdate now always delivers a queued details object before running (makes the UI's queued state live).
  • New DelegationBindings.settingsManager seam; typed unknown-model error; a rejected fallback ModelRuntime.create() is evicted instead of cached forever.

packages/pi-subagents

  • Definition frontmatter supports YAML block lists for tools:/skills: and fails closed: a list-valued key with zero parseable items skips the definition instead of granting pi's default read/bash/edit/write toolset.
  • serviceFor refuses to recreate the fallback service after session_shutdown; unknown-id error wording covers disposed children, not just host restarts.
  • The round-2 session_shutdown → disposeChildrenOf fix is now regression-pinned; the detached-survives-abort test is gate-driven instead of sleep-timed.

packages/server + packages/contracts

  • Children get the host's buildSessionSettings via the new binding, and the curated child extension set includes the oversized-image guard — closes the open feat(host): embed pi-delegation/pi-subagents in the engine host #303 review thread (packaged-app child image reads). The pin exposed and fixes a latent parent-side bug too: pi's SettingsManager.reload() dropped the autoResize:false override during every session assembly.
  • readChildTranscript consults the run registry before throwing: a queued/unflushed child returns { messages: [], status } instead of a false-permanent NOT_FOUND (pi creates the session file only at the first assistant message).
  • The host emits session_shutdown (idempotent) before disposing/trashing in delete flows, so completions arriving during the unbounded trashFile window are suppressed instead of triggering a billed turn on a chat being deleted.
  • An undelivered-completion sweep (on agent_settled and post-reload, guarded by hasQueuedMessages and the transcript-as-delivery-record) redelivers background completions lost to queue drains or mid-run session.reload().
  • New subagent.abort wire method (PROTOCOL_VERSION 54), lineage-checked like subagent.getTranscript.

apps/web

  • The transcript dialog gains a Stop control for live background runs (wired to subagent.abort); background-ack cards note that runs survive a chat Stop.
  • Hydrated non-terminal background acks probe run status once and swap to a "no longer running" state after a host restart, instead of promising a completion forever.
  • Aborted foreground runs show a warning state (data-outcome) instead of the green success check; the queued card state now renders on the live path.

e2e

  • New no-agent spec subagents-ui.spec.ts (hydrated three-state Agent cards, completion turn, disk-transcript dialog, restart-reconciliation lost state) — the subagent UI previously had zero commit-gate coverage. New fixture helper seeds child transcripts under the delegation root.
  • The pure-pi smoke cleans up its copied credentials on every exit path.

Deliberately not changed (recorded design decisions): per-child session GC ("no per-parent GC in V1"), within-lineage provider-mirror semantics, WorkspaceProvider.dispose sync typing, vanilla-pi /reload child disposal.

Testing

  • Every behavior fix carries a regression test verified to fail on the unfixed code (fix reverted, test observed red, fix restored).
  • bun run test — 14/14 tasks green (server 870, web 909, pi-delegation 44, pi-subagents 46+).
  • bun run typecheck, bun run lint, bun run check:deps, bun run check:boundaries, bun run check:seams — green.
  • Full no-agent e2e suite: all 8 shards passed (132s), including the new subagents-ui.spec.ts.
  • Diff audits: zero suppressions, zero new code comments.

@jetbrains-air jetbrains-air 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.

Approved — ready to merge.

jetbrains-air[bot]
jetbrains-air Bot previously approved these changes Aug 30, 2026

@jetbrains-air jetbrains-air 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.

Approved — ready to merge.

@jetbrains-air jetbrains-air 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.

Approved — ready to merge.

@jetbrains-air jetbrains-air 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.

Approved — ready to merge.

@rsolmano
Rinat S (rsolmano) deleted the subagents-hardening branch September 1, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant