Skip to content

agentHost: subagents#308592

Merged
roblourens merged 6 commits intomainfrom
roblou/only-crow
Apr 10, 2026
Merged

agentHost: subagents#308592
roblourens merged 6 commits intomainfrom
roblou/only-crow

Conversation

@roblourens
Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings April 8, 2026 19:27
@roblourens roblourens self-assigned this Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Subagent and subagent session URI helpers (/subagent/{toolCallId}), plus new mapping for subagent.started events.
  • 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

Comment thread src/vs/platform/agentHost/node/agentService.ts
…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.
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 10, 2026

Screenshot Changes

Base: 6df6bbde Current: ef5851df

Changed (12)

agentSessionsViewer/CompletedRead/Dark
Before After
before after
agentSessionsViewer/CompletedRead/Light
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Dark
Before After
before after
agentSessionsViewer/FailedWithoutDuration/Light
Before After
before after
agentSessionsViewer/WithFileChangesList/Dark
Before After
before after
agentSessionsViewer/WithFileChangesList/Light
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Dark
Before After
before after
agentSessionsViewer/WithBadgeAndDiff/Light
Before After
before after
agentSessionsViewer/BackgroundProvider/Dark
Before After
before after
agentSessionsViewer/BackgroundProvider/Light
Before After
before after
agentSessionsViewer/ClaudeProvider/Dark
Before After
before after
agentSessionsViewer/ClaudeProvider/Light
Before After
before after

…ogressAdapter

completedToolCallToSerialized and toolCallStateToInvocation were not
detecting terminal tools via ToolResultContentType.Terminal content
blocks or setting terminalCommandUri/terminalToolSessionId, causing
6 test failures in CI.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 route parentToolCallId events 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

Comment thread src/vs/platform/agentHost/common/state/sessionState.ts
Comment thread src/vs/platform/agentHost/common/state/sessionState.ts
Comment thread src/vs/platform/agentHost/test/node/agentService.test.ts Outdated
roblourens and others added 2 commits April 9, 2026 20:28
Co-authored-by: Copilot <copilot@github.com>
@roblourens roblourens marked this pull request as ready for review April 10, 2026 04:02
@roblourens roblourens enabled auto-merge (squash) April 10, 2026 04:02
@roblourens roblourens merged commit a4f5119 into main Apr 10, 2026
26 checks passed
@roblourens roblourens deleted the roblou/only-crow branch April 10, 2026 04:56
@vs-code-engineering vs-code-engineering Bot added this to the 1.116.0 milestone Apr 10, 2026
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.

3 participants