agentHost: reconcile MCP server enablement#326063
Draft
connor4312 wants to merge 6 commits into
Draft
Conversation
Use reducer-backed session customizations as the single desired state for MCP and plugin enablement, and reconcile Copilot and Claude runtimes before sends. This keeps harness-provided MCP servers disabled and prevents provider updates from restoring stale enablement. Fixes #325960 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cancel pending Copilot SDK MCP authentication callbacks before invoking mcp.disable. The SDK logs the server as disabled but leaves the RPC pending until the auth callback settles, which otherwise blocks the next send. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Reconciles reducer-backed MCP and plugin enablement with live Copilot and Claude runtimes.
Changes:
- Adds pre-turn MCP reconciliation and Copilot auth cancellation.
- Makes session state authoritative for customization enablement.
- Registers the state manager through dependency injection and expands tests.
Show a summary per file
| File | Description |
|---|---|
src/vs/sessions/AI_CUSTOMIZATIONS.md |
Documents provider reconciliation behavior. |
src/vs/platform/agentHost/test/node/shared/mcpCustomizationController.test.ts |
Tests reducer-backed MCP publication. |
src/vs/platform/agentHost/test/node/mockAgent.ts |
Removes obsolete toggle API mocks. |
src/vs/platform/agentHost/test/node/customizations/claudeSessionClientCustomizationsModel.test.ts |
Updates Claude customization-diff tests. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests Copilot reconciliation and auth cancellation. |
src/vs/platform/agentHost/test/node/copilotAgent.test.ts |
Tests session-isolated plugin enablement. |
src/vs/platform/agentHost/test/node/claudeAgent.test.ts |
Tests Claude reconciliation and plugin rebinding. |
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts |
Removes obsolete toggle side-effect coverage. |
src/vs/platform/agentHost/test/node/agentHostChangesetCoordinator.test.ts |
Updates state-manager DI setup. |
src/vs/platform/agentHost/node/shared/mcpCustomizationController.ts |
Projects desired MCP enablement. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Reconciles Copilot MCP runtime state. |
src/vs/platform/agentHost/node/copilot/copilotAgent.ts |
Uses reducer-backed plugin enablement. |
src/vs/platform/agentHost/node/codex/codexAgent.ts |
Adapts MCP controller construction to DI. |
src/vs/platform/agentHost/node/claude/customizations/claudeSessionClientCustomizationsModel.ts |
Tracks applied Claude plugin paths. |
src/vs/platform/agentHost/node/claude/claudeSdkPipeline.ts |
Adds live MCP reconciliation operations. |
src/vs/platform/agentHost/node/claude/claudeAgentSession.ts |
Applies desired state before Claude turns. |
src/vs/platform/agentHost/node/claude/claudeAgent.ts |
Removes provider-local enablement fan-out. |
src/vs/platform/agentHost/node/agentSideEffects.ts |
Removes customization-toggle provider hooks. |
src/vs/platform/agentHost/node/agentService.ts |
Registers and injects the state manager. |
src/vs/platform/agentHost/node/agentHostTerminalManager.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostSyncOperationProvider.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostStateManager.ts |
Defines the injectable service identifier. |
src/vs/platform/agentHost/node/agentHostServerMain.ts |
Registers state manager during server bootstrap. |
src/vs/platform/agentHost/node/agentHostReviewService.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostPullRequestOperationProvider.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostMain.ts |
Registers state manager during host bootstrap. |
src/vs/platform/agentHost/node/agentHostGitStateService.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostDiscardChangesOperationProvider.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostCommitOperationProvider.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostChangesetService.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostChangesetOperationService.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostChangesetFileMonitorCoordinator.ts |
Converts state-manager dependency to DI. |
src/vs/platform/agentHost/node/agentHostChangesetCoordinator.ts |
Uses DI for coordinator construction. |
src/vs/platform/agentHost/common/agentService.ts |
Removes the obsolete agent toggle API. |
Review details
- Files reviewed: 34/34 changed files
- Comments generated: 3
- Review effort level: Medium
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep CopilotAgentSession.sessionUri anchored to the parent AgentSession while retaining per-chat databases, configuration, edit tracking, and history. Also make MCP desired enablement explicitly parent-aware and preserve raw lookup helpers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #325960
Summary
Details
The original issue affected harness-provided MCP servers. Disabling client-provided MCP customizations prevented them from being published, but built-in runtime servers remained enabled inside the agent harness and could return to an authentication-required state on the next turn.
This change treats
SessionState.customizations[].enabledas desired state and provider SDK status as observed state. Copilot and Claude reconcile those states at their session send boundaries. Provider publication also projects reducer-backed enablement so runtime status refreshes cannot overwrite the user's choice.Copilot plugin enablement now follows the same reducer-backed model, removing the provider-local enablement map and the agent customization-toggle hook. The Agent Host state manager is registered in provider bootstrap DI before agents are constructed.
While validating the fix, we found that Copilot SDK
mcp.disable()logs the server as disabled but does not resolve whileonMcpAuthRequestis pending. The host now cancels the pending auth callback for that server before awaiting disable.Codex remains unchanged because its current app-server API does not support live per-thread MCP enablement changes.
No generated protocol reducer behavior is changed.
Validation
npm run typecheck-clientnpm run valid-layers-check