Repository navigation
agentHost: map remote URIs at consumers, not in the transport - #345306
Merged
Merged
Conversation
Removes EditorRemoteAgentHostTransport. This transport changed URIs in protocol packets for editor-remote windows. It did not change the URIs back in reverse resource requests, so the agent host could not load plugins that are on the remote host. Each connection now supplies a resource URI mapper, and consumers map URIs when they read or write protocol state. - Adds an editor-remote resource URI mapper. The protocol client uses it at its API boundary. A mapper unwraps only the vscode-agent-host URIs of its own connection. - Sends client plugin customizations without change, so the implicit read grant matches the reverse resource request. Sends plugins on the same host as vscode-agent-host-file URIs, so the agent host uses them in place and does not copy them through the client. - Maps customization children through the connection mapper, because the host writes them. Uses the container URI only when this client published it. Shows the customizations of other clients, but does not read or open them. - Maps working directories, folder picker roots, enablement, the terminal cwd, the selected agent, and resource attachments to host space when they are sent, and back when they are read. - Sends the selected agent on queued and steering messages. Before, the agent host cleared the custom agent when it dispatched a queued message. - Adds the local/code-agent-host-uri-mapping lint rule, test URI mappers for each connection kind, and URI-space guidance for agents and reviewers. Fixes #341862 (Commit message generated by Copilot) Co-authored-by: Copilot <[email protected]>
# Conflicts: # src/vs/sessions/contrib/providers/agentHost/browser/agentHostAgentPicker.ts # src/vs/sessions/contrib/providers/agentHost/test/browser/agentHostAgentPicker.test.ts # src/vs/workbench/contrib/chat/browser/agentPluginActions.ts # src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts # src/vs/workbench/contrib/chat/test/browser/agentSessions/resolveCustomizationRefs.test.ts # src/vs/workbench/services/agentHost/test/browser/editorRemoteAgentHostServiceClient.test.ts
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: Anthony Kim (@anthonykim1)Matched files:
|
Dmitriy Vasyura (dmitrivMS)
approved these changes
Oct 31, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Remote URI mismatches can break the selected-agent display after draft publication and allow the first message to bypass plugin loading and load-error guards.
2 open issues
What changed in this PR
This PR moves Agent Host URI conversion out of the transport and into connection-aware consumers. It addresses remote plugin loading failures reported in #341862 while preserving client resource identities and host filesystem paths.
Changes:
- Replaces transport-level rewriting with connection-owned URI mappers.
- Updates customization, session, attachment, and terminal consumers to map resources at their boundaries.
- Adds cross-connection tests, a URI-mapping lint rule, and contributor guidance.
| File | Description |
|---|---|
src/vs/workbench/services/agentHost/test/browser/editorRemoteAgentHostServiceClient.test.ts |
Verifies mapper wiring instead of transport wrapping. |
src/vs/workbench/services/agentHost/common/editorRemoteAgentHostTransport.ts |
Removes the URI-rewriting transport. |
src/vs/workbench/services/agentHost/browser/editorRemoteAgentHostServiceClient.ts |
Supplies the editor-remote mapper. |
src/vs/workbench/contrib/terminal/test/browser/agentHostPty.test.ts |
Tests cwd mapping and foreign-resource preservation. |
src/vs/workbench/contrib/terminal/browser/agentHostPty.ts |
Maps terminal cwd through its connection. |
src/vs/workbench/contrib/editTelemetry/browser/telemetry/agentHostEditMarkerService.ts |
Adds lint exceptions documenting remaining mapping work. |
src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/remoteAgentHostCustomizationHarness.test.ts |
Updates customization provider fixtures. |
src/vs/workbench/contrib/chat/test/browser/aiCustomization/mcpListWidget.test.ts |
Tests foreign-plugin enablement handling. |
src/vs/workbench/contrib/chat/test/browser/aiCustomization/customizationsTelemetryService.test.ts |
Tests ownership-aware source attribution. |
src/vs/workbench/contrib/chat/test/browser/aiCustomization/customizationMigrationServiceImpl.test.ts |
Tests editor-remote root hydration. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/workbenchAgentHostCustomizationService.test.ts |
Tests root, picker, and enablement mapping. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/resolveCustomizationRefs.test.ts |
Tests same-host plugin publication and ownership. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostSkillDiscoveryTestUtils.ts |
Supplies connection context to skill fixtures. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostSessionWorkingDirectorySynchronizer.test.ts |
Tests client comparisons and host-space deltas. |
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostCustomizationService.test.ts |
Tests MCP source mapping and plugin ownership. |
src/vs/workbench/contrib/chat/test/browser/agentPluginActions.test.ts |
Tests decoded plugin enablement routing. |
src/vs/workbench/contrib/chat/test/browser/agentHost/agentHostSessionInputPills.test.ts |
Tests mapped customization reveal targets. |
src/vs/workbench/contrib/chat/common/chatImageExtraction.ts |
Documents a filesystem-image lint exception. |
src/vs/workbench/contrib/chat/common/agentHostSessionCustomizations.ts |
Adds ownership-aware customization URI helpers. |
src/vs/workbench/contrib/chat/browser/widget/chatContentParts/toolInvocationParts/chatMcpAppModel.ts |
Documents MCP resource wrapping exception. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostCustomizationHarness.ts |
Documents explicit filesystem selection unwrapping. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/remoteAgentHostChatContribution.ts |
Passes connection context to customization items. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionListController.ts |
Supplies list mapping and documents legacy exceptions. |
src/vs/workbench/contrib/chat/browser/copilotCliEventsUri.ts |
Documents log and tooling URI exceptions. |
src/vs/workbench/contrib/chat/browser/chatDebug/agentHostLogSources.ts |
Documents remote log filesystem wrapping. |
src/vs/workbench/contrib/chat/browser/aiCustomization/toolsListWidget.ts |
Resolves client plugin identity for source actions. |
src/vs/workbench/contrib/chat/browser/aiCustomization/mcpListWidget.ts |
Uses decoded plugin identities and guards foreign actions. |
src/vs/workbench/contrib/chat/browser/aiCustomization/customizationsTelemetryService.ts |
Resolves owned plugin sources for telemetry. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/stateToProgressAdapter.ts |
Maps restored attachments and feedback resources. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostUntitledProvisionalSessionService.ts |
Publishes active-client state with its mapper. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSnapshotController.ts |
Documents remaining checkpoint mapping work. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionWorkingDirectorySynchronizer.ts |
Maps roots at comparison and dispatch boundaries. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionListStore.ts |
Maps notification directories into client space. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionInputPills.ts |
Supplies client identity to customization indexing. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostResponseFileChanges.ts |
Documents remaining file-change mapping work. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostPolicyUnavailableSession.ts |
Maps saved draft attachments during restoration. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostPolicyContinuation.ts |
Passes the mapper when restoring saved input. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostModeSynchronizer.ts |
Documents remaining mode-identity mapping work. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostFolderPickerActionItem.ts |
Reads client-space session folders. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostCustomizationService.ts |
Maps customization resources, roots, and enablement. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostChatContribution.ts |
Supplies customization mapping while retaining local mode compatibility. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostActiveClientService.ts |
Maps plugins in active-client publications. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentCustomizationItemProvider.ts |
Makes item and mode projection ownership-aware. |
src/vs/workbench/contrib/chat/browser/agentPluginActions.ts |
Matches installed plugins by decoded client URI. |
src/vs/sessions/services/agentHost/test/browser/agentHostCustomizationService.test.ts |
Adds client ownership to service fixtures. |
src/vs/sessions/services/agentHost/browser/agentHostCustomizationService.ts |
Exposes provider client identity to customizations. |
src/vs/sessions/contrib/terminal/browser/sessionsTerminalContribution.ts |
Documents terminal cwd unwrapping exception. |
src/vs/sessions/contrib/terminal/browser/agentHostSessionTaskRunner.ts |
Documents task cwd unwrapping exception. |
src/vs/sessions/contrib/remoteSessions/common/remoteSessions.ts |
Documents workspace argument validation exception. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts |
Adds resource mappers to connection fixtures. |
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostSessionsProvider.ts |
Maps cloned workspaces and documents URI exceptions. |
src/vs/sessions/contrib/providers/remoteAgentHost/browser/devContainerSource.ts |
Documents source filesystem path extraction. |
src/vs/sessions/contrib/providers/remoteAgentHost/browser/devContainerAgentHostService.ts |
Documents pre-connection worktree key handling. |
src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts |
Tests mapped roots, agents, enablement, and diffs. |
src/vs/sessions/contrib/providers/agentHost/test/browser/agentHostSessionFiles.test.ts |
Adds mapper and client identity to fixtures. |
src/vs/sessions/contrib/providers/agentHost/test/browser/agentHostSessionCustomizations.test.ts |
Tests child mapping and foreign-container opacity. |
src/vs/sessions/contrib/providers/agentHost/test/browser/agentHostAgentPicker.test.ts |
Tests agent restoration across connection kinds. |
src/vs/sessions/contrib/providers/agentHost/browser/localAgentHostSessionsProvider.ts |
Uses connection mapping for diff resources. |
src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts |
Maps session roots, selected agents, and enablement. |
src/vs/sessions/contrib/providers/agentHost/browser/agentHostSessionFiles.ts |
Supplies mapping and ownership to customization indexing. |
src/vs/sessions/contrib/providers/agentHost/browser/agentHostAgentPicker.ts |
Resolves selections against client-space agent identities. |
src/vs/sessions/contrib/chat/browser/sessionArtifacts.ts |
Documents local artifact reveal exception. |
src/vs/sessions/contrib/chat/browser/chatBackgroundTool.ts |
Documents background-image filesystem exceptions. |
src/vs/sessions/common/agentHostSessionsProvider.ts |
Adds optional provider client identity access. |
src/vs/sessions/browser/openInVSCodeUtils.ts |
Documents cross-window folder conversion exception. |
src/vs/sessions/browser/actions/vscodeActions.ts |
Documents remote-folder opening exception. |
src/vs/platform/agentHost/test/electron-browser/agentHostProtocolClient.test.ts |
Tests API mapping and reverse-read grant identity. |
src/vs/platform/agentHost/test/common/testAgentHostResourceUriMappers.ts |
Adds shared connection and strict test mappers. |
src/vs/platform/agentHost/test/common/agentHostResourceUriMapper.test.ts |
Adds mapper contract tests. |
src/vs/platform/agentHost/test/common/agentHostFileSystemProvider.test.ts |
Tests editor-remote mapping and foreign authorities. |
src/vs/platform/agentHost/common/agentHostUri.ts |
Adds editor-remote mapping and connection-scoped unwrapping. |
src/vs/platform/agentHost/browser/agentHostProtocolClient.ts |
Applies resource mapping at API boundaries. |
eslint.config.js |
Enables the URI-mapping rule for workbench and sessions. |
.github/skills/customizations-in-the-agent-host/SKILL.md |
Documents customization URI ownership. |
.github/instructions/agent-host-uri-spaces.instructions.md |
Defines URI-space boundaries and testing guidance. |
.eslint-plugin-local/tests/code-agent-host-uri-mapping.test.ts |
Tests lint detection, exemptions, and scope. |
.eslint-plugin-local/code-agent-host-uri-mapping.ts |
Adds the connection-aware URI-mapping lint rule. |
Review effort: Balanced
This was referenced Oct 31, 2026
2 tasks done
Ladislau Szomoru (lszomoru)
added a commit
that referenced
this pull request
Nov 6, 2026
…346553) * agentHost: open Working Set files of remote windows as remote files In a window attached to a remote (WSL, SSH, containers), the ambient agent host resolves with the `local` authority. The Working Set, its Keep/Undo matching, and the editor review converted changeset files with `toAgentHostUri(file, authority)`, which leaves `local` file URIs unwrapped. Clicking a changed file then opened the remote path on the client's disk, which a Windows client shows with backslashes and reports as not found. #345031 fixed this through the connection's mapper authority, but #345306 changed the editor-remote mapper to return `vscode-remote` URIs, so the authority fell back to `local` again. Map the file through the owning connection's `resourceUris.fromAgentHost` instead, so it opens as the workspace's file, while recorded contents stay Agent Host content URIs. The tests now use the real editor-remote mapper. Fixes #345420 Co-authored-by: Copilot <[email protected]> * agentHost: map turn changes through the owning connection's resource URIs Address review feedback: the changeset helper now takes the owning connection, so callers can no longer pass a mapper built from an authority. The per-response changes provider uses its connection's resourceUris for both changeset and response-part files, which removes its remaining TODO(agent-host-uri) bypasses. Recorded contents stay Agent Host content URIs. The provider tests now run across every Agent Host connection kind, including the strict exactly-once mapper. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
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.

agentHost: map remote URIs at consumers, not in the transport
Removes EditorRemoteAgentHostTransport. This transport changed URIs in protocol packets for
editor-remote windows. It did not change the URIs back in reverse resource requests, so the
agent host could not load plugins that are on the remote host. Each connection now supplies a
resource URI mapper, and consumers map URIs when they read or write protocol state.
A mapper unwraps only the vscode-agent-host URIs of its own connection.
reverse resource request. Sends plugins on the same host as vscode-agent-host-file URIs, so
the agent host uses them in place and does not copy them through the client.
Uses the container URI only when this client published it. Shows the customizations of other
clients, but does not read or open them.
agent, and resource attachments to host space when they are sent, and back when they are read.
custom agent when it dispatched a queued message.
kind, and URI-space guidance for agents and reviewers.
Fixes #341862
(Commit message generated by Copilot)
How to test
chat.pluginLocationsin Remote settings). Give it an agent and aPreToolUsehook that returns"permissionDecision": "ask"or"deny".agenthost.loghas nonot grantederrors and noSyncing pluginline for the plugin.Validation
npm run typecheck-client: passed.npm run eslint -- src/vs/workbench src/vs/sessions src/vs/platform/agentHost: passed (7,601 files).node --test .eslint-plugin-local/tests/code-agent-host-uri-mapping.test.ts: passed (35 tests).npm run valid-layers-check: passed../scripts/test.sh --reporter dot --runGlob "vs/{workbench/contrib/chat/test/browser,workbench/contrib/chat/test/common,workbench/contrib/terminal/test/browser,workbench/services/agentHost/test,sessions/contrib/providers,sessions/services/agentHost,sessions/contrib/remoteSessions,sessions/contrib/agentFeedback,sessions/contrib/chat,sessions/contrib/terminal,sessions/browser,platform/agentHost/test/{common,browser,electron-browser}}/**/*.test.js": passed (23,945 passing, 0 failing) after the merge withmain../scripts/test.sh --reporter dot --run src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts: passed (350 passing) after the merge fix for repository cloning.PreToolUsehook. The plugin loaded in place, the hook asked for and denied tool calls, remote attachments reached the model as host paths, and the custom agent stayed selected across queued turns.