Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds “subagent” support to the Agent Host protocol + VS Code chat UI so that a tool call can spawn a child (subagent) session, and the client can subscribe to/stream that child session (including inner tool calls) grouped under the parent subagent invocation.
Changes:
- Extend the AHP protocol/state model with
ToolResultContentType.Subagentand subagent session URI helpers (/subagent/{toolCallId}), plus new mapping forsubagent.startedevents. - Update the renderer/session handler and progress adapters to detect subagent content, propagate
subAgentInvocationId, and observe/stream child sessions into parent progress. - Add unit + integration coverage for subagent content mapping, reconnection, and child-session streaming behavior.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts | Adds tests for subagent toolSpecificData extraction + update notification behavior. |
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostSubagent.integrationTest.ts | New integration tests covering snapshot restore, reconnection, and streaming updates for subagent sessions. |
| src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatToolInvocation.ts | Adds a mechanism to notify observers when toolSpecificData changes (non-observable field). |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentContentPart.ts | Updates UI part to re-read metadata when subagent toolSpecificData is updated after initial render. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts | Adds subagent content detection/serialization, subAgentInvocationId plumbing, and running toolSpecificData updates. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Observes subagent child sessions and forwards child tool calls into parent progress grouped by subAgentInvocationId. |
| src/vs/platform/agentHost/test/node/sessionStateManager.test.ts | Adds tests for subagent URI helper functions. |
| src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts | Adds test ensuring SDK subagent.started maps to subagent_started. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Adds tests for creating/routing/completing/cancelling/removing subagent sessions. |
| src/vs/platform/agentHost/test/node/agentEventMapper.test.ts | Tests extracting subagent metadata from tool arguments into _meta. |
| src/vs/platform/agentHost/node/sessionStateManager.ts | Adds prefix-based session URI discovery to support cleanup of subagent sessions. |
| src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts | Maps subagent.started SDK events to protocol subagent_started events. |
| src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts | Classifies subagent-spawning tools via getToolKind(...): 'subagent'. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Emits subagent_started progress events from the SDK wrapper. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Updates session message typing to include subagent-start events. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Creates/routs events into subagent sessions; injects subagent content into parent tool call; cleans up on cancel/dispose. |
| src/vs/platform/agentHost/node/agentService.ts | Restores subagent sessions on subscribe and injects subagent content into completed tool calls during turn reconstruction. |
| src/vs/platform/agentHost/node/agentEventMapper.ts | Populates _meta with subagent metadata parsed from tool arguments for early UI rendering. |
| src/vs/platform/agentHost/common/state/sessionState.ts | Adds subagent content extraction helper + subagent session URI helpers. |
| src/vs/platform/agentHost/common/state/sessionReducers.ts | Extends getToolKind to include 'subagent'. |
| src/vs/platform/agentHost/common/state/protocol/version/registry.ts | Updates protocol action version registry (includes SessionDiffsChanged mapping). |
| src/vs/platform/agentHost/common/state/protocol/state.ts | Adds ToolResultContentType.Subagent and IToolResultSubagentContent to tool result union. |
| src/vs/platform/agentHost/common/state/protocol/reducers.ts | Handles SessionDiffsChanged in the protocol session reducer. |
| src/vs/platform/agentHost/common/state/protocol/actions.ts | Adds SessionDiffsChanged action type and interface (generated). |
| src/vs/platform/agentHost/common/state/protocol/action-origin.generated.ts | Updates action unions and dispatchability table (generated). |
| src/vs/platform/agentHost/common/state/protocol/.ahp-version | Bumps synced AHP protocol version hash. |
| src/vs/platform/agentHost/common/agentService.ts | Extends agent progress event types with IAgentSubagentStartedEvent and toolKind 'subagent'. |
Copilot's findings
- Files reviewed: 27/27 changed files
- Comments generated: 2
…ld sessions instead Inner tool calls from subagent sessions are no longer stored in the parent turn with _meta.parentToolCallId. Instead: - Server: _buildTurnsFromMessages skips inner events (parentToolCallId), _restoreSubagentSession builds child session turns from raw messages - Client: _enrichHistoryWithSubagentCalls subscribes to child sessions during history restore, injects serialized inner tool calls with subAgentInvocationId set Also fixes hygiene: replace 'in' operator with hasKey in agentSideEffects.test.ts, exclude .jsonl from copyright filter.
Contributor
Screenshot ChangesBase: Changed (12) |
…ogressAdapter completedToolCallToSerialized and toolCallStateToInvocation were not detecting terminal tools via ToolResultContentType.Terminal content blocks or setting terminalCommandUri/terminalToolSessionId, causing 6 test failures in CI.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds end-to-end “subagent” support to the Agent Host pipeline so a tool call that spawns a subagent creates/targets a child session, and the UI can render/group inner tool calls under the parent subagent widget (including restore-from-history behavior).
Changes:
- Extend agent/protocol and Copilot event mapping to emit/handle
subagent_started, create subagent sessions, and routeparentToolCallIdevents into the child session. - Update chat progress adaptation/session handler to surface subagent tool invocations and splice child-session tool calls into parent history/progress (via
subAgentInvocationId). - Add/expand unit tests and fixtures validating subagent session creation, routing, history restore, and UI metadata updates.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/agentSessions/stateToProgressAdapter.test.ts | Adds test coverage for subagent tool metadata and updateRunningToolSpecificData. |
| src/vs/workbench/contrib/chat/common/model/chatProgressTypes/chatToolInvocation.ts | Adds a helper to notify observers when toolSpecificData changes. |
| src/vs/workbench/contrib/chat/browser/widget/chatContentParts/chatSubagentContentPart.ts | Adjusts subagent title rendering and updates title when tool metadata arrives late. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts | Teaches progress/history conversion about subagent tool calls and subAgentInvocationId; updates terminal/subagent handling. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts | Observes child subagent sessions, enriches history with inner tool calls, and forwards child progress into the parent session. |
| src/vs/platform/agentHost/test/node/test-cases/subagent-session.jsonl | Adds a JSONL fixture representing a real subagent session event stream. |
| src/vs/platform/agentHost/test/node/mockAgent.ts | Expands mock agent message types to include subagent-start events. |
| src/vs/platform/agentHost/test/node/mapSessionEvents.test.ts | Verifies raw SDK subagent.started maps to protocol subagent_started. |
| src/vs/platform/agentHost/test/node/agentSideEffects.test.ts | Adds tests for subagent session creation, routing, cancellation/completion, and content preservation. |
| src/vs/platform/agentHost/test/node/agentService.test.ts | Adds restore tests for subagent sessions (including fixture-based restore). |
| src/vs/platform/agentHost/test/node/agentHostStateManager.test.ts | Adds tests for subagent session URI helper utilities. |
| src/vs/platform/agentHost/test/node/agentEventMapper.test.ts | Tests extracting subagent metadata from toolArguments into _meta. |
| src/vs/platform/agentHost/node/copilot/mapSessionEvents.ts | Maps SDK subagent.started into agent-host subagent_started events. |
| src/vs/platform/agentHost/node/copilot/copilotToolDisplay.ts | Classifies task as a subagent toolKind for renderer hints. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Forwards SDK subagent-start events through the session progress stream. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Updates message typing to include subagent-start events. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Manages subagent session lifecycle and routes parentToolCallId progress into child sessions. |
| src/vs/platform/agentHost/node/agentService.ts | Builds/restores parent turns without inner subagent events; restores child sessions on subscribe. |
| src/vs/platform/agentHost/node/agentHostStateManager.ts | Adds helper to list session URIs by prefix (used for subagent cleanup). |
| src/vs/platform/agentHost/node/agentEventMapper.ts | Injects subagent metadata into _meta from tool arguments at tool_start. |
| src/vs/platform/agentHost/common/state/sessionState.ts | Adds subagent content extraction and subagent session URI helper functions. |
| src/vs/platform/agentHost/common/state/sessionReducers.ts | Adds helpers to read VS Code-specific _meta fields (toolKind, language). |
| src/vs/platform/agentHost/common/agentService.ts | Extends agent event types to include subagent_started and toolKind: 'subagent'. |
| extensions/copilot/src/extension/prompts/node/agent/openai/hiddenModelBPrompt.tsx | Formatting-only bullet indentation change in prompt text. |
| build/filters.ts | Excludes *.jsonl from copyright header filtering. |
Copilot's findings
- Files reviewed: 24/25 changed files
- Comments generated: 7
bhavyaus
approved these changes
Apr 10, 2026
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.
No description provided.