Skip to content

Agent Host session customizations are not scoped to the session's working directory in multi-root workspaces #328021

Closed

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

  1. Have two folders, A and B, each with its own customizations (e.g. .github/instructions, skills/agents, and MCP servers in .vscode/mcp.json).
  2. Open a multi‑root workspace containing both A and B in the Editor Window.
  3. Create or resume an Agent Host session and pick folder A as its working directory.
  4. 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 resolveCustomizationRefs and registered via registerForAgent(sessionType) in agentHostActiveClientService.ts. The resulting bundle is broadcast to every active session of that harness via session/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 global IMcpService.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

  1. DonJayamanne commented on Aug 18, 2026

    @DonJayamanne
    ContributorAuthor

    Fixed

  2. added this to the 1.135.0 milestone on Aug 18, 2026
  3. locked and limited conversation to collaborators on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions