Skip to content

Fix remote agent-host workspace URI translation - #333296

Draft
Dileep Yavanmandha (dileepyavan) wants to merge 3 commits into
microsoft:mainfrom
dileepyavan:DileepY/AHP_sandboxing
Draft

Fix remote agent-host workspace URI translation#333296
Dileep Yavanmandha (dileepyavan) wants to merge 3 commits into
microsoft:mainfrom
dileepyavan:DileepY/AHP_sandboxing

Conversation

@dileepyavan

@dileepyavan Dileep Yavanmandha (dileepyavan) commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #331566 — Agent file tools incorrectly prompt "Allow reading file outside of workspace?" for the current workspace in WSL. The same URI mismatch also affects Remote SSH.

The editor supplies workspace directories as vscode-remote: URIs, but the agent host runs on the remote machine and needs host-local file: URIs. AHP carries these values as strings inside JSON frames, so the regular remote IPC URI-object transformation does not apply. This breaks workspace containment checks and can cause customization watchers to fail with ENOPRO.

Changes

  • Add EditorRemoteAgentHostTransport, an editor-remote connection adapter that reuses the existing createURITransformer rather than introducing new conversion rules.
  • Convert outgoing working directories for session/chat creation, configuration requests, terminal creation, and directory-change actions. Only remote URIs matching the connected authority are converted.
  • Restore workbench directory identities in incoming session listings, snapshots, notifications, folder-picker metadata, and reconnect snapshots/replayed actions. Correlate JSON-RPC response IDs with their request methods.
  • Wire the adapter into EditorRemoteAgentHostServiceClient and unwrap the shared protocol client's session-list directory wrappers.
  • Add regression coverage for multi-root directories, authority casing, query/fragment preservation, response correlation, lifecycle cleanup, immutability, and preserving opaque message/configuration content.

Permission checks and sandbox policy are unchanged. Existing persisted sessions with incorrect host-side directory URIs are not migrated; use a new session when verifying.

Normalize remote workspace directory URIs at the editor AHP boundary and restore workbench identities in responses and updates. Preserve existing permission checks and cover creation, reconnects, and multi-root updates.

Fixes microsoft#331566

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Dileep Yavanmandha <dileepy@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 29, 2026 00:46

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.

Copilot review overview

Review tier: Balanced
Findings: 2 Medium severity

新建议题s introduced by this change (2)
Severity Finding
Medium severity src/​vs/​workbench/​services/​agentHost/​common/​editorRemoteAgentHostTransport.tsSessionWorkingDirectoryReplaced is the one directory action not translated here. On an…
Medium severity src/​vs/​workbench/​services/​agentHost/​browser/​editorRemoteAgentHostServiceClient.ts — The shared protocol client also adds a singular workingDirectory containing the same…
What changed in this PR

Adds remote Agent Host URI translation between workbench vscode-remote: identities and host-local file: URIs.

Changes:

  • Introduces a URI-translating AHP transport.
  • Integrates it with the remote service client.
  • Adds transport and session-listing regression tests.
File Description
editorRemoteAgentHostTransport.ts Translates directory-bearing protocol messages.
editorRemoteAgentHostServiceClient.ts Wires the adapter and unwraps listed roots.
editorRemoteAgentHostTransport.test.ts Tests translation and lifecycle behavior.
editorRemoteAgentHostServiceClient.test.ts Tests integration and listed identities.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +123 to +127
case ActionType.SessionWorkingDirectorySet:
case ActionType.SessionWorkingDirectoryRemoved:
case ActionType.ChatWorkingDirectorySet:
case ActionType.ChatWorkingDirectoryRemoved:
return { ...action, directory: map(action.directory) };
Comment on lines +249 to +252
return sessions.map(session => ({
...session,
workingDirectories: session.workingDirectories?.map(fromAgentHostUri),
}));
注册 for free to join this conversation on GitHub. Already have an account? 登录 to comment

标签

None yet

项目

None yet

Development

Successfully merging this pull request may close these issues.

Agent file tools incorrectly prompt "Allow reading file outside of workspace?" for the current workspace in WSL

2 participants