Repository navigation
Description
Summary
In the Editor Window, Agent Host session customizations are not scoped to the session's working directory. When a multi‑root workspace (more than one folder) is open, every Agent Host session receives customizations aggregated from all workspace folders — instructions, prompts, skills, agents, hooks, and MCP servers configured in VS Code — regardless of which folder that session actually selected as its primary/working directory.
So if you open a multi‑root workspace with folders A and B and create/resume a session anchored to folder A, that session also gets folder B's customizations and MCP servers. That is wrong: a session's customizations should follow the session's own working directory (or directories), not the whole window's set of folders.
Note: this is an existing behavior, independent of any in‑flight work.
Scope / preconditions
- Editor Window (not the Agents window).
- A multi‑root workspace with more than one folder open.
- Applies to Agent Host sessions (e.g. Copilot Agent Host).
Steps to reproduce
- Have two folders, A and B, each with its own customizations (e.g.
.github/instructions, skills/agents, and MCP servers in.vscode/mcp.json). - Open a multi‑root workspace containing both A and B in the Editor Window.
- Create or resume an Agent Host session and pick folder A as its working directory.
- Inspect the customizations/MCP servers available to that session.
Expected
The session sees only the customizations and MCP servers relevant to its own working directory (folder A), not folder B's.
Actual
The session sees customizations and MCP servers from all workspace folders (A and B) — instructions/prompts/skills/agents/hooks and MCP servers configured in VS Code (.vscode/mcp.json, user, remote).
Root cause
The Agent Host customization sync is computed per harness (session type), not per session, and enumerates the workspace globally:
- The active‑client customization refs are resolved once per harness in
resolveCustomizationRefsand registered viaregisterForAgent(sessionType)inagentHostActiveClientService.ts. The resulting bundle is broadcast to every active session of that harness viasession/activeClientSet. - File‑based customizations come from
enumerateLocalCustomizationsForHarness, which lists prompt files across the workspace storage sources (all folders) with no per‑session working‑directory filter. - MCP servers come from
collectNonPluginMcpServers, which iterates the globalIMcpService.servers(all folders) —.vscode/mcp.json, user, and remote — again with no per‑session working‑directory filter.
Because the bundle is per‑harness and workspace‑wide, a session whose working directory is a single folder (or a folder outside the workspace, or a workspace‑less/scratch session) still receives customizations and MCP servers aggregated from all workspace folders.
Impact
- Customizations and MCP servers leak across folders into sessions that are not scoped to them.
- In a multi‑root workspace, a session anchored to one folder can pick up unrelated (and potentially heavier or sensitive) MCP servers and instructions from other folders.
Suggested direction
Scope the synced customizations/MCP servers to the session's working directory set (index 0 = primary, plus any additional roots the session actually spans) rather than to all workspace folders. This likely requires making the customization resolution session‑aware rather than purely per‑harness.
Activity
DonJayamanne commentedon Aug 18, 2026
Fixed