Skip to content

Support multi-root Agent Host session metadata - #328863

Merged
DonJayamanne merged 2 commits into
mainfrom
don/agents/agents-window-multi-root-support-study
Aug 3, 2026
Merged

Support multi-root Agent Host session metadata#328863
DonJayamanne merged 2 commits into
mainfrom
don/agents/agents-window-multi-root-support-study

Conversation

@DonJayamanne

Copy link
Copy Markdown
Contributor

Summary

  • send and persist the originating multi-root workspace URI and name in Agent Host session metadata
  • use workspace-file identity for Editor-window multi-root session filtering
  • cover direct, provisional, rebound, fork, restore, and startup-cache paths
  • remove the temporary workspace-scoped membership memento

The corresponding Agent Host Protocol request metadata change was merged in microsoft/agent-host-protocol#379. This PR intentionally does not update .ahp-version: a full sync from current AHP main also includes unrelated protocol 0.8 changes that require a separate referenced ToolInput adoption.

Out of scope

Agents Window workspace grouping and disabling the workspace-section + action will be handled in a separate PR.

Validation

  • npm run typecheck-client
  • npm run valid-layers-check
  • npm run precommit
  • focused Agent Host transport, lifecycle, persistence, filtering, and cache unit tests
  • AHP npm test, Rust clippy, and cargo test --workspace

Persist Editor workspace provenance on Agent Host sessions and use it for authoritative multi-root session filtering. Remove the temporary workspace membership memento.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 3, 2026 22:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Replaces the temporary workspace membership memento with durable Agent Host multi-root workspace metadata.

Changes:

  • Forwards and validates _meta.multiRoot during session creation.
  • Persists metadata across forks, restoration, and startup caching.
  • Filters Editor sessions by workspace-file identity.
Show a summary per file
File Description
.github/skills/sessions/SKILL.md Documents metadata-based filtering.
src/vs/platform/agentHost/browser/remoteAgentHostProtocolClient.ts Sends creation metadata.
src/vs/platform/agentHost/common/agentService.ts Adds creation metadata API.
src/vs/platform/agentHost/common/state/protocol/common/commands.ts Adds protocol request metadata.
src/vs/platform/agentHost/common/state/sessionState.ts Defines validated multi-root metadata helpers.
src/vs/platform/agentHost/node/agentService.ts Persists, restores, and inherits metadata.
src/vs/platform/agentHost/node/protocolServerHandler.ts Forwards protocol metadata.
src/vs/platform/agentHost/test/common/sessionWorkspacelessMeta.test.ts Tests metadata validation.
src/vs/platform/agentHost/test/electron-browser/remoteAgentHostProtocolClient.test.ts Tests client forwarding.
src/vs/platform/agentHost/test/node/agentService.test.ts Tests persistence and restoration.
src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts Tests server forwarding.
src/vs/sessions/contrib/providers/agentHost/AGENT_HOST_SESSIONS_PROVIDER.md Documents persistence behavior.
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts Preserves metadata in startup cache.
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts Adds cache coverage.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Adds metadata to direct creation.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListStore.ts Uses workspace-file filtering.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostUntitledProvisionalSessionService.ts Creates Editor workspace metadata.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostWorkspaceSessionMembershipStore.ts Removes the membership memento.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Updates filtering and creation tests.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostUntitledProvisionalSessionService.test.ts Tests provisional metadata paths.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostWorkspaceSessionMembershipStore.test.ts Removes obsolete memento tests.

Review details

  • Files reviewed: 21/21 changed files
  • Comments generated: 3
  • Review effort level: Balanced

Comment thread src/vs/platform/agentHost/node/agentService.ts Outdated
Apply workspace-file filtering across folder-count transitions, sanitize provider metadata before database fallbacks, and exercise cache deserialization in tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

Suppressed comments (2)

src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostUntitledProvisionalSessionService.ts:306

  • This folder-count gate drops provenance for sessions created after a .code-workspace is reduced to one (or zero) folders. WorkbenchState.WORKSPACE is determined by the presence of workspace.configuration, not by folder count (configurationService.ts:184-192), so those are still workspace-file sessions; unlike sessions created before the folder change, they fall back to path filtering and can disappear when folders change again. Remove the folder-count condition and key this metadata solely on the workspace-file identity.
			|| workspace.folders.length < 2

src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListStore.ts:377

  • extUriBiasedIgnorePathCase treats every non-file scheme as case-insensitive (resources.ts:340-343). For the remote workspace URIs this feature explicitly supports, two distinct case-sensitive paths such as /work/Demo.code-workspace and /work/demo.code-workspace therefore compare equal and expose the wrong workspace's sessions. Inject IUriIdentityService and compare with its provider-aware extUri.isEqual instead.
				&& extUriBiasedIgnorePathCase.isEqual(URI.parse(multiRoot.workspaceFile), workspace.configuration);
  • Files reviewed: 21/21 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@DonJayamanne
DonJayamanne marked this pull request as ready for review August 3, 2026 23:29
@DonJayamanne
DonJayamanne enabled auto-merge (squash) August 3, 2026 23:29
@DonJayamanne
DonJayamanne merged commit dce0034 into main Aug 3, 2026
30 checks passed
@DonJayamanne
DonJayamanne deleted the don/agents/agents-window-multi-root-support-study branch August 3, 2026 23:52
@vs-code-engineering vs-code-engineering Bot added this to the 1.133.0 milestone Aug 3, 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