fix(acp): forward subagent session events to ACP client#21801
Open
jasonmj wants to merge 4 commits intoanomalyco:devfrom
Open
fix(acp): forward subagent session events to ACP client#21801jasonmj wants to merge 4 commits intoanomalyco:devfrom
jasonmj wants to merge 4 commits intoanomalyco:devfrom
Conversation
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
afa6984 to
22d75e5
Compare
22d75e5 to
6c5db7b
Compare
Author
|
Not sure how I can move this forward, but I am keeping the PR up to date. |
6c5db7b to
48e1f31
Compare
|
Need this too |
6b3ef56 to
4620720
Compare
When a prompt is run through the Task tool, events arrive with a child session ID that is not directly tracked by ACPSessionManager. Add resolveRootSession() which walks the parentID chain via the SDK to find the nearest ACP-tracked ancestor, caching results to avoid repeated lookups. Replace all sessionManager.tryGet() calls in handleEvent with resolveRootSession() so that tool call and message delta events from sub-agent sessions are correctly forwarded to the ACP client.
4620720 to
f917dc3
Compare
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