Skip to content

fix(acp): forward subagent session events to ACP client#21801

Open
jasonmj wants to merge 1 commit intoanomalyco:devfrom
jasonmj:fix/acp-subagent-events
Open

fix(acp): forward subagent session events to ACP client#21801
jasonmj wants to merge 1 commit intoanomalyco:devfrom
jasonmj:fix/acp-subagent-events

Conversation

@jasonmj
Copy link
Copy Markdown

@jasonmj jasonmj commented Apr 10, 2026

Issue for this PR

Closes #21802

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

ACPSessionManager only tracks sessions explicitly created or loaded by the ACP client (session/new, session/load). When the Task tool spawns a subagent, it calls Session.create({ parentID: ... }) internally, producing a child session with its own ID that is never registered in the session manager.

In handleEvent(), all three event cases (permission.asked, message.part.updated, message.part.delta) call this.sessionManager.tryGet(sessionID) and return early if the result is undefined. This means every event from a subagent session is silently dropped — none of the subagent's tool calls, streamed text, or permission requests reach the ACP client.

The fix adds a resolveRootSession() method that, when a session ID is not directly tracked, walks the parentID chain via sdk.session.get() until it finds a known ACP-tracked ancestor. Events from child sessions are then forwarded to the ACP client attributed to the root session ID. A childToRootSession cache avoids repeated SDK calls for the same child session across multiple events.

How did you verify your code works?

Tested with the agent-shell Emacs ACP client. Before the fix, running a prompt that triggered the Task tool showed no subagent activity. After the fix, subagent tool calls, streamed text, and permission dialogs all appear in the parent session's buffer. TypeScript type-check passes with no errors.

Screenshots / recordings

N/A — CLI/protocol change with no UI.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Child sessions created by the Task tool have their own session IDs
that are not registered in ACPSessionManager. This caused all
message.part.updated, message.part.delta, and permission.asked
events from subagents to be silently dropped in handleEvent().

Add resolveRootSession() which walks the parentID chain via the SDK
to find the nearest ACP-tracked ancestor session. Events from child
sessions are now forwarded to the ACP client attributed to the root
session ID, making subagent activity visible in clients like
agent-shell.

A childToRootSession cache avoids repeated SDK calls for the same
child session across multiple events.
@github-actions github-actions bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found one potentially related PR:

Related PR:

The current PR (#21801) addresses a different aspect of the same broader issue: making subagent activity visible to ACP clients. PR #21111 handles session metadata updates while #21801 handles real-time event forwarding.

No exact duplicate PRs found.

@github-actions github-actions bot removed needs:issue needs:compliance This means the issue will auto-close after 2 hours. labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

ACP clients cannot see subagent activity from Task tool

1 participant