Skip to content

[Feature] Emit subagent lifecycle events over ACP (child run IDs, per-child status and result) and support per-child cancel #1891

Description

@addyCooks

Description

Over ACP, a subagent run is visible only as the parent's agent tool call. The client gets no child run ID, no parent link, no per-child status or result, and cannot cancel one child. The only cancel is the whole turn.

I'd like Nanocoder to emit subagent lifecycle events to ACP clients and accept a per-child cancel, in a way clients can detect, and without changing what clients that ignore the events see today.

This issue is about the child run itself: its identity, status, final result and cancel. The results of tool calls inside a subagent, and routing subagent approvals by session, are tracked in #1105.

Tracked from Nano-Collective/nanocoder-desktop#12 (item 5). Related: #1105, #1156, #1080 and #1019 (earlier subagent approval fixes).

Use Case

Nanocoder Desktop's success item SP-05 is "delegate a bounded subtask, observe the child run, and stop it when needed". It wants to show each child as its own run with live status, attribute approval requests to the right child, and let the user stop one child without cancelling the whole turn. The desktop stores one record per run (child ID, parent run, subagent name, status), so it needs those four fields from Nanocoder.

Today:

  • Progress reaches the client as a polled title on the parent's agent card, refreshed every 1.5 seconds.
  • When several subagents run at once, the card shows only the one with the most tokens.
  • There is no ID that ties a subagent:-prefixed permission request to a particular child.
  • "Stop" on a child can only cancel the whole turn.

Any ACP client that shows subagents has the same limits. The desktop ships a fallback that renders plain tool cards, so this is not blocking. It is needed for the full SP-05 experience, which the desktop plans by its Milestone 1.

Proposed Solution

All of this is additive and ignorable by clients that don't know about it.

  1. A subagent notification. For example _nanocoder/subagent (ACP reserves the underscore prefix for custom methods), carrying:
    • the sessionId
    • the parent tool call ID
    • a child run ID
    • a parent run ID, empty for children of the root turn, so nested subagents form a tree
    • the subagent name
    • a status: started, progress, completed, failed or cancelled
    • progress fields (token count, tool call count, last tool)
    • on completion, the result or error summary
  2. Per-child cancel. An extension method such as _nanocoder/cancelSubagent {sessionId, childRunId}, backed by a per-child abort controller derived from the turn's signal. Cancelling the whole turn still aborts every child. A cancelled child returns a "cancelled" result to the parent so the parent can continue.
  3. Attribution of approvals. Include the child run ID in the _meta of the existing subagent: permission requests.
  4. Capability advertising. List the extension under _meta in agentCapabilities, so clients detect support from the capability and never need to compare Nanocoder versions.
  5. Unchanged for other clients. Keep the existing polled title and subagent:-prefixed approvals as they are.

Alternatives Considered

  • Do nothing. Clients keep a tool-card fallback and whole-turn cancel.
  • Make each child its own ACP session with a parent link. That would let the existing session/cancel work per child, but it is a much larger change and affects session storage and retention.
  • Only add child IDs to the existing polled card title. Cheap, but it gives no status events or per-child cancel, and clients would have to parse text.

Additional Context

  • I have searched existing issues to ensure this is not a duplicate
  • This feature aligns with the project's goals (local-first AI assistance)

Current behavior, checked against main at fc01e23:

  • source/acp/acp-conversation.ts (~L667-704): while an agent tool call runs, a 1.5 s interval reads getAllSubagentProgress(), picks the entry with the highest tokenCount, and updates the parent card's title. Progress entries from earlier calls are skipped.
  • source/tools/agent-tool.tsx creates a randomUUID() agent ID for every subagent (~L68 for parallel runs, ~L138 for single runs) and passes it to the executor. It is never sent to the client.
  • source/subagents/subagent-executor.ts: subagents receive the turn's abort signal (~L223, L635, L798), so cancel is whole-turn only. MAX_SUBAGENT_DEPTH = 2 and MAX_CONCURRENT_AGENTS = 5.
  • source/utils/tool-approval-queue.ts: one process-wide approval slot, with "last writer wins". acp-conversation.ts (~L166-177) documents that overlapping sessions can answer each other's approvals. ACP: thread sub-agent tool results back so every call is announced and settles with its real status #1105 tracks fixing this.
  • source/acp/acp-conversation.ts (~L98-161): an approved subagent call is marked completed at approval time, before it runs. ACP: thread sub-agent tool results back so every call is announced and settles with its real status #1105 tracks fixing this too.
  • docs/features/acp.md lists these as known limitations.

Implementation Notes (optional)

This overlaps with #1105. Its session-keyed bridge, with begin and end callbacks around each subagent tool call, is the natural place to emit events, and it also fixes the approval routing that attribution depends on. I'd suggest landing #1105 first and building this on top of it.

The child ID already exists (agentId), and the executor already updates per-agent progress (updateSubagentProgressById, ~L622), so the data for started and progress events is available. The _nanocoder/subagent name and field names above are suggestions. The maintainers should decide the real shape.

Acceptance criteria:

  • A subagent run emits started, progress and a final completed, failed or cancelled event with a stable child run ID.
  • Events carry the sessionId and parent run ID, and stay correct when two sessions run subagents.
  • Concurrent children each emit their own events.
  • subagent: permission requests carry the child run ID.
  • A client can cancel one child without ending the turn, and the parent receives a "cancelled" result.
  • Cancelling the turn cancels all children.
  • Clients that ignore the extension see the same behavior as today.
  • The extension is advertised under _meta in agentCapabilities.
  • Docs describe the events and the cancel method.

Test plan:

  • ACP spec: a single subagent emits the full event sequence.
  • ACP spec: two concurrent subagents emit separate event streams.
  • ACP spec: a nested subagent reports its parent run ID.
  • ACP spec: per-child cancel ends one child and the turn continues.
  • ACP spec: whole-turn cancel ends all children.
  • ACP spec: two sessions with subagents don't mix events.
  • Regression: the polled title and approvals still work when events are ignored.

Out of scope: how a client displays children, the subagent depth and concurrency limits, tool-call results inside a subagent, and approval routing (both tracked in #1105).

Activity

  1. added
    enhancement
    help wanted
    architecture
    area:vscode
    area:agent
    on Oct 26, 2026
  2. added
    needs-triage
    on Oct 26, 2026
  3. self-assigned this
    on Oct 26, 2026
  4. removed
    needs-triage
    on Oct 26, 2026
  5. added a commit that references this issue on Oct 29, 2026
    e30cc60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

architecturearea:agentarea:vscodeenhancementhelp wanted

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions