Skip to content

agentHost: reconcile MCP server enablement#326063

Draft
connor4312 wants to merge 6 commits into
mainfrom
connor/mcp-disable-reconciliation
Draft

agentHost: reconcile MCP server enablement#326063
connor4312 wants to merge 6 commits into
mainfrom
connor/mcp-disable-reconciliation

Conversation

@connor4312

Copy link
Copy Markdown
Member

Fixes #325960

Summary

  • reconcile session customization enablement into the live Copilot and Claude runtimes before sending a turn
  • use reducer-backed session customizations as the single desired-state source for plugin and MCP enablement
  • preserve desired enablement when providers republish runtime MCP state
  • cancel pending Copilot MCP authentication before disabling a server so the SDK disable RPC can settle

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[].enabled as 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 while onMcpAuthRequest is 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-client
  • Agent Host provider and reconciliation unit tests
  • hygiene checks
  • npm run valid-layers-check

connor4312 and others added 2 commits July 15, 2026 15:18
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>
Copilot AI review requested due to automatic review settings July 15, 2026 22:20

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

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

Comment thread src/vs/platform/agentHost/node/claude/claudeAgentSession.ts Outdated
Comment thread src/vs/platform/agentHost/node/claude/claudeAgentSession.ts Outdated
Comment thread src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
connor4312 and others added 3 commits July 15, 2026 16:37
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>
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.

Disabled MCP server becomes enabled again after a turn

2 participants