Add chat.{agents,editor}.claude.preferAgentHost EXP settings#321020
Merged
Conversation
Introduces a pair of EXP-backed boolean settings that select between the Copilot extension's Claude implementation (EH) and the agent host's Claude implementation (AH) on a per-surface basis: - chat.agents.claude.preferAgentHost gates the Agents Window - chat.editor.claude.preferAgentHost gates the regular workbench sidebar Both implementations register normally. Per-window suppression happens declaratively in three places: 1. The extension's `chatSessions` contribution `when` clause branches on `isSessionsWindow` to read the surface-appropriate setting. 2. `CopilotChatSessionsProvider` (Agents Window-only consumer) reads the agents-window setting reactively. 3. `AgentHostContribution._shouldRegisterAgent()` mirrors the same per-window rule for the AH side, reactively listening for config flips. Net effect: exactly one Claude implementation per window, live-switchable without a reload. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The block explained a decision that lives in `AgentHostContribution`, not here. Removing it brings this file back to its pre-PR state. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds two EXP-backed settings to choose (per window surface) whether Claude sessions are fulfilled by the Copilot extension (EH) or by the agent host (AH), aiming to ensure only one Claude provider is registered per window and allowing live switching.
Changes:
- Introduces
chat.agents.claude.preferAgentHostandchat.editor.claude.preferAgentHostsettings and wires them into chat configuration. - Gates Claude provider registration on both sides: EH via Copilot extension
chatSessionscontributionwhen, AH viaAgentHostContributionfiltering. - Updates Agents Window Copilot sessions provider logic + tests to suppress EH-Claude when AH-Claude is preferred.
Show a summary per file
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/browser/chat.shared.contribution.ts | Registers the two new EXP-backed settings in chat configuration. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts | Filters AH provider registration per window based on the new settings and reacts to config flips. |
| src/vs/sessions/contrib/providers/copilotChatSessions/browser/copilotChatSessionsProvider.ts | Suppresses EH-Claude session type when Agents Window prefers AH-Claude; adds reactive updates. |
| src/vs/sessions/contrib/providers/copilotChatSessions/test/browser/copilotChatSessionsProvider.test.ts | Adds coverage for preferAgentHost gating and reactivity in sessionTypes. |
| src/vs/platform/agentHost/common/agentService.ts | Defines exported setting IDs (agents/editor) and documents intended behavior. |
| src/vs/platform/agentHost/node/agentHostMain.ts | Clarifies that Claude registers when reachable and renderer enforces per-window surfacing. |
| extensions/copilot/package.json | Updates EH Claude chatSessions contribution when clause to be surface-aware via new settings. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 3
…gents Two stale "Requires a window reload" notes in the setting descriptions remained from when this was env-var-gated. The implementation is now reactive in both EH and AH paths, so toggling takes effect live. Also restrict `_authenticateWithServer` to the allowed agents instead of all agents in root state — token resolution work for a Claude provider suppressed in this window was wasted effort. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
justschen
approved these changes
Jun 11, 2026
zht5128
pushed a commit
to zht5128/vscode
that referenced
this pull request
Jun 11, 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.
Summary
Introduces a pair of EXP-backed boolean settings that select between the Copilot extension's Claude implementation (EH) and the agent host's Claude implementation (AH) on a per-surface basis:
chat.agents.claude.preferAgentHost— gates the Agents Windowchat.editor.claude.preferAgentHost— gates the regular workbench sidebarBoth implementations register normally. Per-window suppression happens declaratively in three places:
chatSessionscontributionwhenclause (extensions/copilot/package.json) — branches onisSessionsWindowto read the surface-appropriate setting.CopilotChatSessionsProvider(Agents Window-only consumer) — readschat.agents.claude.preferAgentHostreactively in the existing_claudeEnabledlistener.AgentHostContribution._shouldRegisterAgent()— mirrors the same per-window rule on the AH side; reactive listener flips the bridge live when the relevant setting changes.Net effect: exactly one Claude implementation per window, live-switchable without a reload.
Why per-window rather than process-level
Earlier iterations forwarded the resolved preference to the agent host process via an env var so the AH would only register Claude when at least one preference was true. That coupled main-process spawn-time logic to UI lifecycle and required a window reload when toggling. The current design keeps the AH surface-agnostic (always register if SDK is reachable) and pushes the "which window sees which implementation" decision to the renderer, which already has the per-window context. The cost is constructing a
ClaudeAgentinstance in the AH process that may not be bridged anywhere — small, no SDK load.Relationship to #320896
#320896 adds the same two setting names (plus four more in the family) and gates picker visibility without unregistering. Both providers stay in the registry, hidden only at the dropdown. This PR takes the unregistration path so downstream consumers (command palette, MRU, URI handlers) also see exactly one Claude. The two PRs conflict on the schema declarations; recommend coordinating before merge.
Test plan
copilotChatSessionsProviderunit tests pass (with new cases added forpreferAgentHostreactivity)agents=true, editor=false: Agents Window shows AH-Claude only; sidebar shows EH-Claude onlyagents=false, editor=true: inverseagents=false, editor=false(default): both windows show EH-ClaudeChatSessionsService._evaluateAvailabilitytraces confirm per-windowshouldBeRegisteredmatches the matrix🤖 Generated with Claude Code