Agents window: external agent sessions are only discovered at startup; add refresh/rediscovery
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Type: Bug (with a feature ask at the end)
- VS Code Version: 1.136.2 (commit 88e44fa0e00b08f7758b4f6d05632e4fd5e4df6f, x64)
- OS Version: Ubuntu 22.04.5 LTS (kernel 6.8.0-138-generic)
- Agent: Claude Code CLI (external sessions feature per https://code.visualstudio.com/docs/agents/run/agents-window and https://code.visualstudio.com/docs/agents/run/sessions/manage-sessions)
## Summary
The Agents window discovers external agent sessions (e.g. Claude Code CLI sessions started in a terminal) **only once, when the Agent Host starts**. A session created after VS Code launches never appears in the sessions list — regardless of the External filter setting — until VS Code is fully restarted. Changing `chat.agentSessions.showExternal` only reconciles the sessions already discovered at startup; it does not rescan disk.
## Steps to reproduce
1. Open the Agents window. Set the External filter to "All" (or "Last 7 Days").
2. In a terminal, run `claude` in any directory, have a short conversation, exit.
3. Look for the new session in the Agents window sessions list.
**Expected:** the new external session appears (it is on disk under `~/.claude/projects/...`).
**Actual:** it never appears. Toggling the External filter or the Claude filter does not help. After restarting VS Code, the session appears as expected.
## Evidence from `agenthost.log`
(timestamps are local time, UTC+8)
Discovery ran exactly once, at window startup (10:24):
```
2026-09-09 10:24:26.108 [info] [AgentService] discovery for provider claude: 119 candidate(s) (119 external), 0 registered, 58 already registered, 60 suppressed as subagent/chat backing, 1 skipped as older than 30 days
```
The terminal Claude session in question was created at 15:24 (five hours after that scan) and was therefore never registered. Later filter changes only reconciled already-known sessions — note there is no new `discovery for provider claude` line:
```
2026-09-09 15:29:20.685 [info] [AgentService] showExternalSessions changed 'last30Days' -> 'recent'; queueing session list reconciliation
2026-09-09 15:29:21.097 [info] [AgentService] External session reconciliation done in 411ms (mode: 'recent', previous: 'last30Days'): 2 published, 64 retracted, 2 visible
2026-09-09 15:31:59.269 [info] [AgentService] showExternalSessions changed 'recent' -> 'last30Days'; queueing session list reconciliation
2026-09-09 15:31:59.654 [info] [AgentService] External session reconciliation done in 384ms (mode: 'last30Days', previous: 'recent'): 62 published, 0 retracted, 64 visible
```
## Feature ask
Either (or both) of:
- A **refresh action** in the Agents window sessions list that re-runs external session discovery on demand.
- **Automatic rediscovery** — periodic rescan or a file watcher on the known external session catalogs (`~/.claude/projects`, `~/.copilot`, Codex equivalents), so sessions started while VS Code is running show up without a restart.
From a user's perspective the current behavior looks like the session is simply lost — the docs say external sessions are discoverable via the filter, but no filter value can surface a session created after launch.
— Claude (posted on Eric's behalf via Claude Code)
Contributor guide
Assessment
This issue has not been assessed yet.