Skip to content

agentHost: respect workspace trust#322196

Draft
roblourens wants to merge 3 commits into
mainfrom
agents/plan-see-https-github-com-microsoft-vscode-inter-8c68fddf
Draft

agentHost: respect workspace trust#322196
roblourens wants to merge 3 commits into
mainfrom
agents/plan-see-https-github-com-microsoft-vscode-inter-8c68fddf

Conversation

@roblourens

@roblourens roblourens commented Jun 20, 2026

Copy link
Copy Markdown
Member

Summary

  • treat the local Agent Host process as non-workspace-specific, but block untrusted windows from opening or retaining the local client connection to it
  • require workspace/folder trust before Agent Host session creation and sends in editor and Agents window paths
  • prompt for Agent Host workspace trust instead of silently trusting folders, and mark remote Agent Host workspaces as trust-required

Validation

  • npm run typecheck-client
  • npm run valid-layers-check
  • npm run precommit
  • node --experimental-strip-types build/hygiene.ts src/vs/platform/agentHost/electron-browser/localAgentHostService.ts src/vs/sessions/contrib/chat/browser/newChatWidget.ts
  • ./scripts/test.sh --grep "LocalAgentHostSessionsProvider|RemoteAgentHostSessionsProvider|AgentHostChatContribution|AgentHostTerminalContribution"
  • ./scripts/test.sh --run src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts --run src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts --run src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostTerminalContribution.test.ts

(Written by Copilot)

Prevent untrusted windows from communicating with the local Agent Host while still allowing the process to start. Require folder trust before creating or sending Agent Host sessions, including remote Agent Host workspaces, and prompt instead of silently trusting folders.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 20, 2026 03:18

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

This PR integrates VS Code’s workspace trust model into Agent Host flows, aiming to prevent untrusted workspaces from initiating or using Agent Host sessions/connections while still allowing the local Agent Host infrastructure to exist independently.

Changes:

  • Introduces a shared AgentHostWorkspaceTrust helper and uses it to require/prompt trust before creating sessions and sending requests (editor + Agents window paths).
  • Gates local Agent Host surfacing/registration and terminal integration based on workspace trust.
  • Marks remote Agent Host workspaces as trust-required and updates/extends tests accordingly.
Show a summary per file
File Description
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostTerminalContribution.test.ts Stubs workspace trust service for terminal contribution tests.
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts Stubs trust management/request services for chat contribution tests.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostWorkspaceTrust.ts New helper to check/prompt/require trust for Agent Host-backed URIs.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostTerminalContribution.ts Disables Agent Host terminal integration when workspace is untrusted.
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts Requires trust before creating new Agent Host sessions (when a working directory is present).
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts Clears/blocks local agent registrations when workspace trust is revoked; prevents activation while untrusted.
src/vs/sessions/contrib/workspace/browser/workspaceFolderManagement.ts Prompts for trust instead of silently trusting folders for trust-required workspaces.
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts Adds coverage ensuring remote sends prompt/require trust for the underlying folder.
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts Marks remote Agent Host workspaces as requiresWorkspaceTrust: true.
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts Adds tests for untrusted workspace behavior and trust-gated sends.
src/vs/sessions/contrib/providers/agentHost/browser/localAgentHostSessionsProvider.ts Stops exposing/using the local Agent Host connection while untrusted; clears root-state-derived surfaces.
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts Introduces trust gating for new session backend start + requires trust before send for new sessions.
src/vs/sessions/contrib/chat/browser/newChatWidget.ts Reuses the shared trust prompt message for folder trust requests.
src/vs/platform/agentHost/electron-browser/localAgentHostService.ts Makes the renderer-side local Agent Host MessagePort connection conditional on workspace trust and refactors proxy forwarding accordingly.

Copilot's findings

  • Files reviewed: 14/14 changed files
  • Comments generated: 4

Comment thread src/vs/platform/agentHost/electron-browser/localAgentHostService.ts
Comment thread src/vs/platform/agentHost/electron-browser/localAgentHostService.ts Outdated
Comment thread src/vs/platform/agentHost/electron-browser/localAgentHostService.ts Outdated
Comment thread src/vs/platform/agentHost/electron-browser/localAgentHostService.ts
roblourens and others added 2 commits June 20, 2026 11:59
Respond to Copilot review feedback by resyncing the local renderer connection when the agent host setting changes, reporting disabled and untrusted states distinctly, and dropping in-flight local connections if trust changes before connection publication. (Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve current main conflicts after upstream Agent Host session-list changes and keep the local Agent Host workspace-trust gating intact. (Written by Copilot)

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.

2 participants