fix(acp): forward subagent session events to ACP client#21801
Open
jasonmj wants to merge 1 commit intoanomalyco:devfrom
Open
fix(acp): forward subagent session events to ACP client#21801jasonmj wants to merge 1 commit intoanomalyco:devfrom
jasonmj wants to merge 1 commit intoanomalyco:devfrom
Conversation
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.
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
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. |
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #21802
Type of change
What does this PR do?
ACPSessionManageronly tracks sessions explicitly created or loaded by the ACP client (session/new,session/load). When the Task tool spawns a subagent, it callsSession.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) callthis.sessionManager.tryGet(sessionID)and return early if the result isundefined. 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 theparentIDchain viasdk.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. AchildToRootSessioncache 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