microsoft / microsoft/vscode

Agent Host "Allow remote session access" hangs and triggers Unexpected end of JSON input on VS Code 1.133.0

Open
#331,039 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

Does this issue occur when all extensions are disabled?: Not tested yet. The failing UI/action appears to be part of VS Code's built-in Agent Host / Remote Connections functionality.

- VS Code Version: 1.133.0
- Commit: a5b500951314efd502d07465bd138dfbd714a960
- OS Version: Windows 10 x64

Steps to Reproduce:

1. Open VS Code and start/open a session using the **Copilot** agent harness.
2. Confirm that the Agent Host session itself works normally.
3. Click the **Allow remote session access** radio-tower icon shown at the bottom of the Copilot session.
4. Observe the `Remote Connections` output.
5. Observe the `Main` log at the same time.

## Actual Result

`Remote Connections` immediately logs:

```text
2026-08-15 15:30:35.082 [info] Starting tunnel hosting...
```

At essentially the same timestamp, `Main` logs the following from `AgentHost:stderr`:

```text
2026-08-15 15:30:35.083 [error] [AgentHost:stderr] SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at fl (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:433:119096)
at fl (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:433:119061)
at Du.onRawMessage (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:433:120000)
at el.value (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:433:119386)
at k._deliver (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:433:3617)
at k._deliverQueue (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:433:3706)
at k.fire (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:433:4040)
at MessagePortMain.P (file:///C:/Users//AppData/Local/Programs/Microsoft%20VS%20Code//resources/app/out/vs/platform/agentHost/node/agentHostMain.js:431:13792)
at MessagePortMain.emit (node:events:509:28)
at Object.emit (node:electron/js2c/utility_init:2:2934)
```

A second related stack is logged at the same timestamp through `onBuffer`:

```text
SyntaxError: Unexpected end of JSON input
at JSON.parse ()
...
at pl.onBuffer (...)
...
at MessagePortMain.P (...)
```

The remote connection never finishes establishing. The radio-tower icon remains in the **Establishing tunnel connection...** state.

I can reproduce this consistently: clicking **Allow Remote Connections** immediately triggers the JSON parsing error.

## Expected Result

Clicking **Allow Remote Connections** should successfully enable remote session access and eventually report that the tunnel/remote connection is ready, instead of remaining stuck at:

```text
Starting tunnel hosting...
```

## Additional Information

The Agent Host itself otherwise starts and works normally. For example:

```text
Agent Host process started successfully
AgentService initialized
Registering agent provider: copilotcli
[ProtocolServer] Initialize: clientId=..., protocolVersions=[0.8.0, 0.7.0, 0.6.0, 0.5.2, 0.5.1]
[WebSocketProtocol] Server listening on socket \\.\pipe\vscode-agent-host-...
[Copilot] CopilotClient started successfully
[Copilot] Found 1 sessions
[AgentService] Restored session ...
[Copilot] Found multiple available models
```

Normal Copilot Agent Host sessions continue to work. The failure appears specifically when enabling **Allow remote session access**.

I also tested the browser Agents window. Since the remote connection never finishes establishing, it continues to show:

```text
No Host
```

At the time of the repro, the standard VS Code Remote Tunnel CLI was not running:

```powershell
code tunnel status
```

returned:

```json
{"tunnel":null,"service_installed":false}
```

The `Remote Tunnel Service` log also reports:

```text
[info] No other tunnel running
```

This may be related to other recent Agent Host `Unexpected end of JSON input` / MessagePort deserialization reports, but I cannot confirm that the root cause is the same.

I can provide additional trace logs or test an Insiders/candidate build if useful.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure by using the Agent Host's Allow remote session access action, then compare the Remote Connections and Main logs. Start with the AgentHost:stderr and onBuffer paths shown in agentHostMain.js, and use code tunnel status as a baseline; done means the tunnel reaches a ready state without Unexpected end of JSON input.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, typescript, vscode
Domain
desktop, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.