microsoft / microsoft/vscode

Agents Window shows terminal launch error when switching between remote Agent Host sessions

Open
#333,079 0 comments 0 reactions 1 assignee Claimed by @anthonykim1 View on GitHub
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

:robot: AI Assisted bug report

## Description

Switching between remote Agent Host sessions in the Agents Window repeatedly shows an error notification:

> The terminal process failed to launch: Connection disposed: tunnel:.

The selected chat session otherwise loads and remains usable.

## Steps to Reproduce

1. Connect to multiple remote Agent Host sessions through tunnels.
2. Open a session containing historical terminal tool calls.
3. Switch between remote sessions.
4. Observe the terminal launch error notification.

## Expected Behavior

Historical hidden terminal attachments should be restored or quietly discarded when their previous connection has been disposed. No error should be shown if the active chat session reconnects successfully.

## Actual Behavior

Opening a session creates a hidden `Agent Host Terminal`. Its startup immediately fails against a disposed tunnel connection, producing a generic terminal launch notification.

Relevant redacted log sequence:

```text
terminalInstance#ctor (...) [{"name":"Agent Host Terminal", ...}]
Terminal process exit [...]
terminalInstance#dispose (...)
[AgentHostPty] Failed to dispose host terminal:
Connection disposed: tunnel:
```

This repeats when switching sessions, with different tunnel identifiers.

## Additional Context

This may involve restoration of PTY-backed historical tool output using a stale `IAgentConnection`.

Possibly related:

- #315126
- #317832
- #331889 / #331908

The complete logs contain authentication and personal information, so they are not attached. Additional sanitized excerpts can be provided if needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.