Skip to content

ACP: thread sub-agent tool results back so every call is announced and settles with its real status #1105

Closed

Description

@will-lamerton

Follow-up to #1019 / #1080, split out as agreed in review.

What works now

#1080 routed sub-agent tool calls that need approval to session/request_permission. Those calls are announced as a tool_call before the request, prefixed subagent:, and titled with the sub-agent name.

What is still missing

Sub-agent tools that need no approval are never announced at all. signalToolApproval in source/subagents/subagent-executor.ts is only reached for calls that need approval; everything else runs without touching the ACP layer. So a client gets cards for the approval-gated subset of a sub-agent's work and no visibility into the rest. A read-heavy sub-agent can run a dozen tools and show nothing.

An approved call is marked completed at approval time, not when it runs. The handler in source/acp/acp-conversation.ts settles the card on approval because the sub-agent layer never reports results back. That was a deliberate trade against leaving the card spinning forever, but it means a client sees completed for a tool that may then fail, and never sees real output.

Both have the same root cause: SubagentExecutor does not thread its tool results out to the ACP conversation. Fixing that closes both at once - announce every sub-agent tool call, then update it with the real terminal status and output.

Also unresolved: mode and alwaysAllow are ignored inside sub-agents

needsApprovalForTool is passed only {mode: this.currentMode()}, and the ACP executor is constructed in source/plain/initialize.ts with the default parentMode: 'normal' and no mode resolver. A yolo or auto-accept session is therefore prompted inside a sub-agent for a tool it would not be prompted for at top level. Pre-existing, but #1080 is what made it visible. Noted in that changeset.

Also unresolved: overlapping sessions can cross-answer approvals

The approval slot in source/utils/tool-approval-queue.ts is a process-wide singleton with last-writer-wins semantics. runAcpConversation scopes its handler to the turn with a LIFO-correct disposer, which stops the handler outliving the turn, but turnActive is per session (source/acp/acp-session.ts), so two sessions can be mid-turn at once. For that overlap the later installer answers the earlier session's approvals against the wrong session id and abort controller, which the client rejects as invalid params.

Closing it needs the slot keyed by session id, or an approval channel threaded through SubagentExecutor - the same threading the two items above want, so it is probably one piece of work.

Activity

  1. addyCooks commented on Sep 1, 2026

    @addyCooks
    Collaborator

    Hey @will-lamerton

    I'd like to take this one
    I have a working fix locally that closes all four items in one change, since they do share the root cause you identified.

    Approach: replace the process-wide approval slot (on the ACP path) with a session-keyed tool bridge a registry mapping a session id to a {begin, end} channel.

    • SubagentExecutor calls begin() for every tool call, not just approval-gated ones, and reports the real status and output via end() — so read-heavy sub-agents are visible, and a card is never marked completed at approval time.
    • runAcpConversation registers its bridge under session.sessionId for the turn, so overlapping sessions can't answer each other's approvals.
    • The bridge owns the approval decision, using session.developmentMode + nonInteractiveAlwaysAllow the same authority the top-level loop uses. That closes the mode/alwaysAllow gap without giving the shared executor a mode it can't correctly hold across sessions.
    • Card ids become subagent:<agentId>:<callId>, so a second run's call_1 can't upsert onto a finished card.

    The allow-list guard deliberately still runs ahead of the announcement, and the global-slot path is untouched when no bridge is registered, so the Ink UI is unaffected.

    Testing: 25 new tests covering an approved-then-failing tool reporting failed, a no-approval tool being announced and settled, yolo/alwaysAllow not prompting inside a sub-agent, and two turns overlapping in chat() each answering their own session. Typecheck, lint, format and knip clean.

    Could you assign this to me? Happy to open the PR right away.

  2. added
    area:agent
    area:vscode
    bug
    on Oct 7, 2026
  3. added a commit that references this issue on Oct 29, 2026
    6493fe0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:agentarea:vscodebug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions