Repository navigation
agentHost: keep subagent and Fusion phase notifications out of the parent chat - #341987
Draft
Justin Chen (justschen) wants to merge 2 commits into
Draft
Justin Chen (justschen) wants to merge 2 commits into
Justin Chen (justschen) wants to merge 2 commits into
Conversation
…rent chat System notifications (e.g. background shell/agent completions) were always rendered in the root turn, ignoring the SDK envelope `agentId` that marks a notification delivered to a subagent, and ignoring a running Fusion child-chat phase. A turn-starting notification for an idle subagent could even start a new root turn. - Route `agentId` notifications to the subagent chat when it is running, drop them when the agent is unknown, and carry a turn-starting notice for an idle subagent as the message of its next resumed turn. - Render root notifications during a running child-chat Fusion phase in that phase, matching its tool calls. - Restore `agentId` notifications into the subagent transcript. Co-authored-by: Copilot <[email protected]>
Contributor
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Replay can create a completed subagent turn from multiple idle notifications even when the subagent never resumes.
1 open finding
What changed in this PR
Routes subagent and child-phase notifications away from the parent chat while preserving inline Fusion phase behavior.
Changes:
- Routes live notifications to the appropriate chat and defers idle-subagent notifications.
- Restores attributed notifications into subagent transcripts.
- Adds live and replay regression tests.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts |
Tests subagent notification replay. |
src/vs/platform/agentHost/test/node/copilotTestEvents.ts |
Adds notification agent identity to test events. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests live subagent and Fusion notification routing. |
src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts |
Routes restored notifications into subagent transcripts. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Routes live notifications and queues idle-subagent messages. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Keep turn-starting notifications for idle subagents outside the restored transcript until replay reaches actual subagent activity. This avoids creating a completed turn for a subagent that never resumes and matches the live notification handling. Co-authored-by: Copilot <[email protected]>
This branch has not been deployed
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.

Problem
In a HydraFusion session, the root chat showed "
Type-check client sourcescompleted" under the Main pass phase. The agent host log showed the Fusion phase solver had started an asyncbash(shellIdtypecheck). The runtime then delivered itsshell_completedsystem.notificationwithout anagentId, and the agent host rendered it in the root turn.The investigation found two separate leaks:
system.notificationhandler and the restore mapper ignored the SDK envelopeagentId, which is set when a notification is delivered to a sub-agent. Every notification was rendered in the parent turn. If the parent was idle, a turn-starting notification could even start a new root turn.Note: #341951 moved primary, draft, and follow-up passes inline, so the exact Main-pass case in the report now renders in the main chat by design. Child-chat phases and subagent notifications still leaked.
Changes
copilotAgentSession.ts)agentIdis never rendered in the parent chat.agentIdis unknown, the notification is dropped and logged._fusionPhaseParentToolCallIdrouting. Inline phases still render in the root turn.mapSessionEvents.ts): notifications withagentIdare restored into the subagent transcript, or become the message of a resumed subagent turn, and never into the parent turn.Known limitation: restore does not route unattributed notifications to Fusion phases. Phase starts are not persisted before the notification, and the runtime's synthetic
read_bashfollow-ups restore the same way.Validation
npm run build-fast -- --client-only(passed), then./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --run src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts: 1333 passing./scripts/test.sh --reporter dot --runGlob "vs/platform/agentHost/test/node/**/*.test.js": 11601 passing, 14 failing. All 14 failures are incopilotAgent.test.ts(external chat discovery, state-file resolution, debug logs). The same 14 also fail on the base commit without this change, so they are pre-existing and environmental.npm run typecheck-client: passednpm run eslint -- <5 changed files>: passedNew tests:
system.notification› notifications delivered to a subagent never surface in the parent chatsystem.notification› notifications during a running Fusion phase follow its tool callsmapSessionEvents› restores notifications delivered to a subagent in its transcript, never the parent