Skip to content

Claude sessions never appear in Agent Sessions view — chat discovery race condition swallows "SDK not ready" as success #334170

Open

Agent suggestions

Public preview

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/<timestamp>/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

Activity

  1. Eric-SHENNONGSHI commented on Sep 3, 2026

    @Eric-SHENNONGSHI
    Author

    Confirmed workaround

    For anyone hitting this before it's fixed upstream: manually invoking workbench.action.chat.agentHost.downloadAgentSdk with arg "claude" (e.g. via a custom keybinding) reliably fixes this, whereas workbench.action.chat.agentHost.reloadAgentConfiguration does not — it still races and logs SDK not downloaded yet; deferring chat discovery even when triggered manually well after startup.

    The difference (from agentHostMain.js):

    • reloadAgentConfiguration → _restartChatDiscovery() directly, with no wait for SDK readiness — hits the same race as automatic startup discovery.
    • downloadAgentSdk → _download() → await this._agent.downloadSdk() (which is ensureAvailable(): awaits canLoadWithoutDownload(), and if false, awaits full loadSdkRoot()) → then _lookAgain() → restartChatDiscovery() + refreshModels(). Because this awaits actual SDK availability before re-running discovery, it doesn't race and the previously-hidden Claude sessions correctly appear in the Agent Sessions view afterward.

    Example keybinding used to confirm this:

    {
        "key": "ctrl+k ctrl+r",
        "command": "workbench.action.chat.agentHost.downloadAgentSdk",
        "args": "claude"
    }

    This doesn't fix the underlying startup race (Claude sessions still won't appear automatically on a fresh window until this is manually triggered), but it's a reliable manual recovery in the meantime.

  2. nooma-42 commented on Sep 4, 2026

    @nooma-42

    same here

  3. kasra0 commented on Sep 18, 2026

    @kasra0

    same here

  4. interconnectedMe commented on Oct 8, 2026

    @interconnectedMe

    Possibly related to the missing-session-list issue I just reported: #340573

    Claude is one of the affected sources in my VS Code 1.141.0 native Chat Sessions view. The Claude and Codex source filters are enabled, but most existing sessions from both providers are absent after Reset, Refresh, and Reload Window. The Codex local store remains populated, and VS Code's session-state store contains Codex and Claude resource URIs.

    Your reported Claude SDK readiness race and the workbench.action.chat.agentHost.downloadAgentSdk workaround may explain the Claude portion, but do not explain why Codex sessions are also absent. I have not tried that command yet.

  5. interconnectedMe commented on Oct 8, 2026

    @interconnectedMe

    Follow-up to my earlier “possibly related” comment: we have verified a resolution for the Codex portion of #340573.

    "chat.editor.codex.preferAgentHost": false

    Setting this explicitly in the active profile restored Codex history and pinned chats immediately, before a window reload. They opened correctly in editor tabs and survived Developer Reload Window. Rolling back to 1.140.0 alone had not helped; we are now back on 1.141.0 with the setting retained and the Codex workflow working.

    The Codex recovery is separate from the Claude readiness race reported here. Our Claude log also contained SDK not downloaded yet; deferring chat discovery, but we have not verified that it subsequently became ready without discovery retrying, nor verified Claude recovery.

    Details and scope clarification: #340573

  6. interconnectedMe commented on Oct 8, 2026

    @interconnectedMe

    Follow-up: Claude history is now accessible again as well, through a separate recovery step from the Codex preference workaround.

    Before this step, the 1.141.0 agent-host log repeatedly reported:

    [Claude] SDK not downloaded yet; deferring chat discovery
    

    We invoked VS Code's built-in workbench.action.chat.agentHost.downloadAgentSdk command with argument "claude" using a temporary keybinding (removed after testing). The download completed successfully for Claude SDK 0.3.281, then the same running agent host logged:

    [AgentService] discovery for provider claude: 26 candidate(s) (26 external), 26 registered, 0 already registered, 0 suppressed as subagent/chat backing, 0 skipped as older than 30 days
    

    The user then opened a recovered Claude conversation in native Chat and compared it with the Claude Code extension sidebar; the same historical messages were visible in both. This verifies discovery and history access, not sending a new message or post-restart persistence. chat.agentSessions.showExternal was set to last30Days in the active profile during this test.

    This establishes an SDK-availability/discovery prerequisite in our case. It does not establish the specific readiness race in #334170: we did not observe the SDK becoming ready spontaneously after startup while discovery failed to retry. The explicit SDK download successfully triggered discovery without a full window reload. No session-store deletion or index rebuild was needed.

    Codex was restored separately using "chat.editor.codex.preferAgentHost": false. Both recoveries were confirmed on VS Code 1.141.0.

  7. interconnectedMe commented on Oct 15, 2026

    @interconnectedMe

    Follow-up from 2026-10-15 on Ubuntu/Linux x64, now running VS Code 1.142.0 (6d62b1d5dace93a33b3a6d3eca1317bd5e15bcb1) with Claude Code extension 2.1.300.

    Today's symptom is that newly created Claude sessions are missing from the native Chat Sessions sidebar. The user reports that, as far as they can tell, all of today's sessions are absent; we did not manually inspect the entire older history.

    Read-only inspection found:

    • At startup, agenthost.log reports discovery for provider claude: 172 candidate(s) (172 external), 0 registered, 172 already registered, 0 suppressed as subagent/chat backing, 0 skipped as older than 30 days.
    • The agent-host SQLite catalog contains 172 Claude sessions, all classified as external.
    • Three top-level Claude transcript files for this workspace, updated after agent-host startup this morning, have session IDs absent from that catalog.
    • The current Planning workspace's native session cache contains 144 agent-host-claude entries, all unarchived. Older sessions have therefore reached the native data model; this is not evidence of complete discovery failure.
    • The active profile explicitly sets chat.agentSessions.showExternal to last30Days, and the host configuration agrees. No saved provider-exclusion filter was found in the inspected state stores.

    Inspection of the shipped agentHostMain.js shows _startClaudeCodeChatDiscovery() memoizing its discovery promise after success, without a periodic scan or filesystem watcher in that path. The native list store's refresh also returns early once its cache is valid. This is consistent with new external Claude sessions remaining undiscovered after startup.

    We have not restarted the local agent host or fully restarted VS Code during this investigation, so recovery by restart has not yet been verified on this installation. The upstream test plan #331122 recommends Developer: Restart Local Agent Host when new external sessions are not discovered.

    This is a different failure mode from the SDK-readiness race in this issue: today's startup discovery succeeded. Our earlier SDK-download recovery is documented in #340573; today's evidence instead aligns with #335215. Posting this distinction to avoid treating every missing-Claude-session symptom as an SDK-readiness failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions