Claude sessions never appear in Agent Sessions view — chat discovery race condition swallows "SDK not ready" as success
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
### Summary
Claude/Anthropic sessions never appear in the Agent Sessions view because the one-time chat discovery pass for the Claude provider silently "succeeds" (without ever emitting any sessions) when the SDK readiness check happens to return `false` at that exact moment — which happens on effectively every cold start and window reload. Since the SDK readiness check normally flips to `true` only ~2-4 seconds later, the discovery pass never gets a chance to actually list the sessions, and nothing re-triggers it afterward.
### Environment
- VS Code (Stable), Agent Host / Copilot Chat "Agent Sessions" view
- Provider: **Claude** (Anthropic), with prior Claude Code CLI session history already present under `~/.claude/projects/`
- `chat.agentSessions.showExternal` tested with all values (`recent`, `last24Hours`, `last7Days`, `last30Days`) — no effect
- Reproduces on Linux
### Steps to reproduce
1. Have existing Claude Code CLI session history (e.g. sessions created via the Claude CLI/extension on a previous day).
2. Start VS Code fresh (cold start), or use `Developer: Reload Window`, or fully quit and relaunch VS Code.
3. Inspect the agent host log (`~/.config/Code/logs//agenthost.log`). Observe, during the very first chat-discovery pass:
```
[Claude] SDK not downloaded yet; deferring chat discovery
```
4. A few seconds later in the same log, observe the SDK actually becomes available (e.g. `[Claude] Models refreshed (merged). Count: 7, ...`), and new Claude chats can be created/used normally from this point on.
5. Open the Agent Sessions view. No Claude/Anthropic sessions are listed, regardless of the `chat.agentSessions.showExternal` setting.
6. Repeat step 2 (reload window, or fully quit/relaunch) any number of times — the same race recurs on every restart, and Claude sessions never appear.
### Expected
Chat discovery for the Claude provider should retry (or be re-triggered) once the SDK becomes available, so previously-created Claude sessions eventually show up in the Agent Sessions view.
### Actual
Discovery never retries and Claude sessions are permanently absent from the Agent Sessions view for the lifetime of the window, even after the SDK is confirmed ready and chat itself works normally.
### Notes on likely cause
Skimming the shipped `agentHostMain.js`, `_startClaudeCodeChatDiscovery()` wraps its discovery function in a retry helper that appears to retry only when the wrapped function throws. When the SDK-readiness check (`canLoadWithoutDownload()`) returns `false`, the function logs `"SDK not downloaded yet; deferring chat discovery"` and returns normally instead of throwing — which the retry wrapper seems to treat as a completed (non-retryable) attempt. The only other path that seems to re-trigger discovery is a user-facing "download SDK" / "reload agent configuration" flow, which doesn't surface as a prompt when chat itself is already functional (as is the case here, since Claude chats work fine once the SDK is ready — only the *sessions list* is stuck).
### Related
- #332830 (closed) describes a related but distinct symptom: `listSessions` throwing entirely when the Claude catalog is unavailable. This issue is different — discovery doesn't throw/fail loudly, it silently no-ops and is never retried, so the Agent Sessions view just quietly shows nothing for Claude with no error surfaced anywhere.
Contributor guide
Assessment
This issue has not been assessed yet.