Repository navigation
agentHost: anchor Copilot customizations to each chat's own folders - #341694
Merged
Sandeep Somavarapu (sandy081) merged 11 commits intoOct 15, 2026
Merged
Sandeep Somavarapu (sandy081) merged 11 commits into
Sandeep Somavarapu (sandy081) merged 11 commits into
Conversation
Base automatically changed from
agents/block3a-session-state-authority
to
main
October 15, 2026 07:06
…folders A Copilot peer chat in a multi-folder session discovered the session's customizations: the first folder's only (multi-root off) or the union of all folders (multi-root on), instead of those of the folder it works in. A chat's customization anchors are now its own effective working directories (its first, plus its others when multi-root is enabled). Discovery moves out of the session's plugin controller into refcounted per-anchor-set `CustomizationAnchor`s: chats in the same folder share one, a set is never discovered twice, and it is released with the last chat using it and on session finalize. The session's ActiveClient keeps the client tool set and client plugins, so client updates still reach every chat. The published view (`SessionState.customizations`) stays the default chat's and now follows a chat-only move of the default chat; `copilot.sharedCustomizationDirectories` is still written for older builds but no longer read for anchoring. MCP runtime-state publishing is unchanged. Co-authored-by: Copilot <[email protected]>
Pins each rule of the per-chat anchoring fix: - a peer in a session's second folder gets that folder's agents, instructions and workspace MCP servers, not the first folder's (multi-root off) nor the union (multi-root on); its other folders only when multi-root is on; the default chat and the published view are unchanged; - the default chat follows a chat-only move immediately and on relaunch, sharing a peer's discovery there, while `copilot.sharedCustomizationDirectories` is still written for older builds; - the published view stays the default chat's when a peer starts first after a restart; - chats in the same folder share one discovery; - client tool updates reach every chat; - a folder's discovery is released with its last chat and every discovery with the session; - a peer's folder-only MCP server still appears in the session list (MCP runtime-state publishing unchanged); - host session settings anchor to the default chat's own folders. Co-authored-by: Copilot <[email protected]>
… picker list Agent pickers list the session's published customizations, which are the default chat's (Agents window `agentHostAgentPicker` via the provider's `getCustomAgents`, editor `AgentHostCustomizationService.getCustomAgents`, both reading `SessionState.customizations`). With per-chat anchors a peer in another folder could select a listed agent its own folder does not discover, and it would not resolve. When a chat's selected custom agent is not in its own anchor set's snapshot, that one agent is taken from the published (default chat's) anchor set at create, materialize, resume and send. Instructions and skills stay the chat's own folder's. Co-authored-by: Copilot <[email protected]>
…s anchor moves Review findings on the per-chat anchors: - The published view only republished discovery changes of the anchor set it had last read, so after a reanchor (worktree materialization, default-chat resume, a chat-only move) changes in the new folder were dropped until something re-read the view. Changes are now matched by the anchor set's key. A chat-only move of the default chat, which no host operation republishes, publishes the new view once it settles. - A read overlapping session teardown could throw on the disposed published reference, or create discovery that nothing disposes. A disposed controller or anchor set now discovers nothing. Co-authored-by: Copilot <[email protected]>
… the move A chat-only move of the default chat now publishes the new folder's customizations once they settle, so that folder is discovered during the move and the next send shares it instead of discovering it. Co-authored-by: Copilot <[email protected]>
…al paths The same folder reached through different spellings (a symlink such as `/tmp` and `/private/tmp` on macOS, or a different case where paths ignore case) was keyed as two anchor sets, so it was discovered twice. Anchor-set keys are now the comparison keys of the folders' real paths, resolved before a chat acquires its set. Only the key changes: chats keep running in, and anchor sets keep discovering, the folders they were given. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
force-pushed
the
agents/copilot-customization-bug-fix-implementation
branch
from
October 15, 2026 07:12
0db62f7 to
67cd254
Compare
Sandeep Somavarapu (sandy081)
marked this pull request as ready for review
October 15, 2026 07:15
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 15, 2026 07:15
Contributor
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Duplicate discovery anchors, overwritten downgrade roots after repeated moves, and Windows symlink-test portability remain unresolved.
3 open findings
What changed in this PR
This PR makes Copilot customization discovery follow each chat’s own folders while retaining session-wide client contributions.
Changes:
- Introduces shared, reference-counted discovery anchors per folder set.
- Keeps published customizations aligned with the default chat and adds selected-agent fallback.
- Adds regression tests and documents the behavior.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests per-chat discovery, moves, sharing, and cleanup. |
src/vs/platform/agentHost/test/node/agentHostSessionStateOwnershipGuard.test.ts |
Updates the compatibility-metadata allowance. |
src/vs/platform/agentHost/test/node/agentHostSeams.test.ts |
Tests default-chat customization settings. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Implements per-chat anchors and selected-agent fallback. |
src/vs/platform/agentHost/node/agentChatContext.ts |
Derives customization roots from the default chat. |
src/vs/platform/agentHost/AGENTS.md |
Documents discovery ownership and compatibility behavior. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sandeep Somavarapu (sandy081)
requested review from
Vritant Bhardwaj (vritant24)
and removed request for
Vritant Bhardwaj (vritant24)
October 15, 2026 08:07
- Keep the compatibility roots older builds discover from across repeated chat-only moves of the default chat: the roots saved by the first move are preserved instead of being replaced by the intermediate folder. - Re-key live anchor sets once their folders' real paths resolve, so a set acquired under its spelling (e.g. by a client customization sync publishing before a chat launches through a symlink) is shared rather than discovered again. - Create the test's directory link as a junction on Windows, where directory symlinks need extra privileges. Co-authored-by: Copilot <[email protected]>
Aiday Marlen Kyzy (aiday-mar)
previously approved these changes
Oct 15, 2026
…ent restore test The test disposed each AgentService and closed the database without the session state drain that shutdown() performs. When the 250ms mirror flush timer fired before the dispose (as on slower Windows runners), the flush's transaction ran into the closed database, its rollback failed too, and the store logged "AggregateError: Failed to mark the session state mirrored", failing the test's errors assertion. Drain each service's session state store before disposing it, and hold the timer-driven flush in flight across the first dispose so the race is reproduced deterministically. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
requested review from
Aiday Marlen Kyzy (aiday-mar) and
Vritant Bhardwaj (vritant24)
and removed request for
Aiday Marlen Kyzy (aiday-mar) and
Vritant Bhardwaj (vritant24)
October 15, 2026 09:57
Ladislau Szomoru (lszomoru)
previously approved these changes
Oct 15, 2026
…x-implementation Resolve copilotAgent.ts: keep the per-chat customization anchors (anchor acquisition and anchored snapshots at launch, chat backing and resume) and apply 3b's per-chat ShellManager chat argument at the moved call sites. Co-authored-by: Copilot <[email protected]>
Sandeep Somavarapu (sandy081)
requested a review
from Aiday Marlen Kyzy (aiday-mar)
October 15, 2026 13:34
Sandeep Somavarapu (sandy081)
requested review from
Ladislau Szomoru (lszomoru) and
Vritant Bhardwaj (vritant24)
and removed request for
Aiday Marlen Kyzy (aiday-mar),
Ladislau Szomoru (lszomoru) and
Vritant Bhardwaj (vritant24)
October 15, 2026 13:34
…x-implementation Resolve against 3c's chat-owner model, keeping per-chat customization anchors: - agentChatContext.ts: keep the default-chat-folder session settings (main only moved the function) and 3c's createChatOwnerRef. - copilotAgent.ts: anchors keep acquiring from the owner's ActiveClient for the chat's own folders; materialize uses 3c's chat/owner/storage for the snapshot and ShellManager; peer resume and refresh use ownerSession; legacy resume uses the owner ref for MCP, ShellManager and the agent session identity; the default-chat-only move test is isEqual(resource, ownerSession). Co-authored-by: Copilot <[email protected]>
…dget "a read/archive toggle on an un-loaded session persists and publishes without restoring it" waited at most 20 zero-delay ticks for the summary notification. The toggle publishes only after loading the session's central state from SQLite, which on a loaded runner (macOS Electron-Unit) takes longer, so the test read neither the persisted value nor the published status. Wait for the notification itself (bounded), then drain session state and catalog writes before reading, and slow the central state read in the test so a tick-budget wait fails deterministically. Co-authored-by: Copilot <[email protected]>
Ladislau Szomoru (lszomoru)
approved these changes
Oct 15, 2026
Sandeep Somavarapu (sandy081)
deleted the
agents/copilot-customization-bug-fix-implementation
branch
October 15, 2026 15:24
This was referenced Oct 17, 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.


Bug
A Copilot peer chat in a multi-folder session gets the wrong folder's customizations. A peer working in the session's second folder discovered the first folder's agents, instructions, skills and workspace MCP servers (multi-root off), or the union of all folders (multi-root on), because discovery was anchored to the session rather than to the chat. After a chat-only move, the default chat also kept discovering from its previous folder. Claude and Codex already discover from the chat's own folder.
Fix (Copilot only, no protocol change, no Claude/Codex change)
The fix follows the agreed design for per-chat Copilot customization anchors (Copilot provider only).
CustomizationAnchors, one per ordered anchor set, owned by the session'sSessionPluginController. Chats in the same folder share one, a set is never discovered twice, and a set is released with the last chat using it and on session finalize. The session'sActiveClientkeeps the client tool set and client-synced plugins, so client updates still reach every chat. A chat's SDK snapshot is its anchor set's discoveries plus the session's client contributions.SessionState.customizationsstays the default chat's list. It follows a chat-only move of the default chat (no enablement rebase, no project change) and keeps publishing discovery changes after any reanchor.copilot.sharedCustomizationDirectoriesis still written exactly as before, but this build no longer reads it, either in the provider or in the host's session-settings derivation (agentChatContext.ts, consumed only by Copilot)./tmp/...and/private/tmp/...(or through another symlink or casing) is one anchor set. The paths passed to the SDK are unchanged.Decisions and known limitations
main):How to test
Use two folders, each with its own
.github/agents/*.agent.mdand.github/instructions/*.instructions.md.set_workspace. Its replies follow folder 2's instructions only, with multi-root on and off.Validation
All runs were made with
COPILOT_*,AGENT_HOST_*andGITHUB_TOKENunset, at the PR head on top of main (after #341626 merged).npm run typecheck-clientnpm run eslint -- <5 changed .ts files>npm run valid-layers-check./scripts/test.sh --run src/vs/platform/agentHost/test/node/copilotAgent.test.ts --run .../copilotAgentSession.test.ts --run .../agentHostSeams.test.ts --run .../agentHostSessionStateOwnershipGuard.test.ts./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/e2e/providers/copilotAgentHostE2E.integrationTest.ts(strict replay)./scripts/test.sh --grep "AgentHost|Chat"AgentHostChatContributions"clears automatic archive time…", in code this PR doesn't touch; 15/15 runs passed when quiet. #341626 (now on main) rewrote that test to await the store.New tests in
copilotAgent.test.ts(suite "per-chat customization anchors"):agentHostSeams.test.tscovers the host settings derivation.Not run: the broad
AgentHost|Chatsuite after the final rebases; the cross-platform Azure pipeline; the Claude and Codex E2E suites, since no Claude or Codex code changed. The selected-agent fallback couldn't be exercised live, because of the pre-existing client issue above; unit tests and mutations cover it.