Skip to content

Copilot Chat re-walks the entire CLI session store on every refresh — extension host stalls for minutes with a large store #327021

Closed

Description

Description

Summary

The Copilot CLI chat-sessions provider (CopilotCLIChatSessionContentProvider) re-enumerates the entire Copilot CLI session store on every refresh — no incremental update, cache, or cap. provideChatSessionItems (logged as listSessions took <n>ms) calls getAllSessions() and maps every session. It's triggered constantly: a 5s poll runs while any CLI session is active (setInterval(updateActiveSessionsOnly, 5000)), and any session-state change fires _onDidChangeChatSessionItems, each re-triggering the full walk. With a large store this takes seconds to minutes and stalls the extension host Copilot Chat runs on — multiplied across open windows.

Impact

  • Chat turns become very slow.
  • The affected window's UI thread stalls, causing keyboard input lag (keystrokes queue, then burst in).
  • "Extension host unresponsive" events.

Evidence (my machine)

  • Store: ~6,000 CLI sessions / 3.4 GB under ~/.copilot/session-state, plus a 256 MB session-store.db. I drive the CLI from scripts (~300 sessions/day), so it accumulates fast and nothing prunes it.
  • GitHub Copilot Chat.log: listSessions took was typically 2,500–5,500 ms, spiking to 39,000 ms, 71,000 ms, and 312,000 ms (5+ minutes).
  • One window logged 67 listSessions calls totaling ~36 min of extension-host time; another logged 220 calls.
  • After pruning the store to ~670 sessions, listSessions dropped to a steady ~400 ms.

Root cause (bundled dist/extension.js, Copilot Chat 0.58.0)

  • provideChatSessionItems → getAllSessions() enumerates all sessions unconditionally, then Promise.all(map(toChatSessionItem)) over all of them.
  • startActiveSessionPolling() = setInterval(updateActiveSessionsOnly, 5000) while any session is active; changes fire _onDidChangeChatSessionItems → full re-walk.
  • github.copilot.chat.cli.showExternalSessions=false only filters display (per-item shouldShowSession); it does not short-circuit the getAllSessions() walk, so it doesn't address the cost.

Expected

The provider shouldn't do an O(N) full-store enumeration on every refresh/poll. Options: incremental updates for active-session changes; cache with invalidation; pagination/cap; back off the 5s poll; and/or a first-party retention/prune for the CLI session store (it currently grows unbounded — no cleanup command or setting exists).

Workarounds

  • Prune ~/.copilot/session-state + session-store.db (restored ~400 ms).
  • showExternalSessions=false helps partially (skips per-item display work), not the walk.

Environment

  • VS Code 1.130.0 (e5381e4)
  • GitHub Copilot Chat 0.58.0
  • Windows 11, Node ≥ 22

Issue Details

Item Value
Issue Category Performance Issue
Target Agents Window
VS Code Version Code 1.130.0 (e5381e4, 2026-07-21T13:18:50+05:00)
OS Version Windows_NT x64 10.0.26310

Additional Issue Data

issue-data.md

Activity

  1. KHARSHAVARDHAN-eng commented on Jul 22, 2026

    @KHARSHAVARDHAN-eng

    Thanks for the detailed investigation and performance analysis!

    I've been looking into this issue and would be interested in working on a fix if there isn't already an implementation in progress.

    From my initial investigation, it appears the repeated full session enumeration on refresh is indeed the primary performance bottleneck, especially for large CLI session stores.

    Before I start implementing anything, could a maintainer let me know whether this issue is open for external contributions, or if someone on the team is already working on it?

    Thanks!

  2. added
    bug
    on Jul 22, 2026
  3. 3v1n0 commented on Sep 16, 2026

    @3v1n0

    This is definitely an issue, and even more because this happens in a SYNC way in the UI process, blocking it.

    The interface hangs forever of time in some old workspaces I have, making vscode completely unusable without chat.disableAIFeatures:

    2026-09-16 15:18:48.956 [info] [GitExtensionServiceImpl] Initializing Git extension service.
    2026-09-16 15:18:48.956 [info] FetcherService: Experimentation service not available yet, using default fetcher configuration.
    2026-09-16 15:18:48.956 [info] Using the Electron fetcher.
    2026-09-16 15:18:48.956 [info] [GitExtensionServiceImpl] Successfully activated the vscode.git extension.
    2026-09-16 15:18:48.956 [info] [GitExtensionServiceImpl] Enablement state of the vscode.git extension: true.
    2026-09-16 15:18:48.956 [info] [GitExtensionServiceImpl] Successfully registered Git commit message provider.
    2026-09-16 15:18:48.956 [info] ConversationFeature: Waiting for copilot token or BYOK model to activate conversation feature
    2026-09-16 15:18:48.956 [warning] [LanguageModelAccess] LanguageModel/Embeddings are not available without a Copilot token source
    2026-09-16 15:18:48.956 [info] [CopilotCLIModels] Skipping model fetch since there is no Copilot token source
    2026-09-16 15:18:48.956 [info] BYOK: registered 9 provider(s): ollama, anthropic, gemini, xai, openai, openrouter, azure, customoai, customendpoint
    2026-09-16 15:18:48.956 [info] BYOK: fetching known models list
    2026-09-16 15:18:48.956 [info] activationBlocker from 'languageModelAccess' took for 64ms
    2026-09-16 15:18:48.956 [info] [CopilotCLI] OpenTelemetry enabled: exporter=file, source=github.copilot
    2026-09-16 15:18:48.956 [info] BYOK: Copilot Chat known models list fetched successfully.
    2026-09-16 15:18:49.014 [info] [CopilotCLI] MCP server started. Lock file: /home/marco/.copilot/ide/460deacd-a6a6-4ad0-ae74-b2b0fd554bf0.lock
    2026-09-16 15:18:49.014 [info] [CopilotCLI] Server URI: unix:/tmp/mcp-Vfr8j1/mcp.sock#%2Fmcp
    2026-09-16 15:18:49.185 [warning] [LanguageModelAccess] LanguageModel/Embeddings are not available without a Copilot token source
    2026-09-16 15:18:49.241 [info] Logged in as 3v1n0
    2026-09-16 15:18:50.164 [info] Got Copilot token for 3v1n0
    2026-09-16 15:18:50.164 [info] Copilot Chat: 0.64.1, VS Code: 1.136.2
    2026-09-16 15:18:50.224 [info] copilot token sku: copilot_for_business_seat_quota
    2026-09-16 15:18:50.224 [info] ConversationFeature: Activating contributions
    2026-09-16 15:18:50.226 [info] Registering default platform agent...
    2026-09-16 15:18:50.228 [info] copilot token sku: copilot_for_business_seat_quota
    2026-09-16 15:18:50.229 [info] copilot token sku: copilot_for_business_seat_quota
    2026-09-16 15:18:50.229 [info] copilot token sku: copilot_for_business_seat_quota
    2026-09-16 15:18:50.231 [info] copilot token sku: copilot_for_business_seat_quota
    2026-09-16 15:18:50.232 [info] activationBlocker from 'conversationFeature' took for 1641ms
    2026-09-16 15:18:50.233 [info] [context keys] Setting context key: github.copilot-chat.activated
    2026-09-16 15:18:50.234 [info] AuthenticationService: firing onDidAuthenticationChange from handleAuthChangeEvent identity change. Has token: true
    2026-09-16 15:18:50.234 [info] copilot token sku: copilot_for_business_seat_quota
    2026-09-16 15:18:50.245 [info] GithubAvailableEmbeddingTypesManager: Got embeddings. Primary: metis-1024-I16-Binary. Deprecated: 
    2026-09-16 15:18:50.249 [info] Successfully activated the GitHub.vscode-pull-request-github extension.
    2026-09-16 15:18:50.249 [info] [githubTitleAndDescriptionProvider] Initializing GitHub PR title and description provider provider.
    2026-09-16 15:18:50.249 [info] Successfully registered GitHub PR title and description provider.
    2026-09-16 15:18:50.249 [info] Successfully registered GitHub PR reviewer comments provider.
    2026-09-16 15:18:50.249 [info] WorkspaceChunkSearchService: using embedding type metis-1024-I16-Binary
    2026-09-16 15:18:50.957 [info] Fetched model metadata in 2338ms 6c0316c5-a967-472a-b62b-7c8d235df163
    2026-09-16 15:18:51.382 [info] ConversationFeature: BYOK models available
    2026-09-16 15:18:51.382 [info] copilot token sku: copilot_for_business_seat_quota
    2026-09-16 15:18:51.386 [info] Latest entry: ccreq:latest.copilotmd
    2026-09-16 15:18:51.386 [info] ccreq:eab43a97.copilotmd | markdown
    2026-09-16 15:18:54.430 [info] Fetched content exclusion rules for 2 repo(s) in 1460ms
    2026-09-16 15:18:54.430 [info] ccreq:76e0bc4b.copilotmd | markdown
    2026-09-16 15:18:54.432 [info] Fetched content exclusion rules for 10 repo(s) in 1462ms
    2026-09-16 15:18:54.432 [info] ccreq:00fece0b.copilotmd | markdown
    2026-09-16 15:18:54.434 [info] Fetched content exclusion rules for 10 repo(s) in 1464ms
    2026-09-16 15:18:54.434 [info] ccreq:3d5a1a88.copilotmd | markdown
    2026-09-16 15:18:54.481 [info] Fetched content exclusion rules for 10 repo(s) in 1511ms
    2026-09-16 15:18:54.481 [info] ccreq:e95c374b.copilotmd | markdown
    2026-09-16 15:18:54.501 [info] Fetched content exclusion rules for 10 repo(s) in 1532ms
    2026-09-16 15:18:54.501 [info] ccreq:2e55b36d.copilotmd | markdown
    2026-09-16 15:21:43.254 [info] [CopilotCLIChatSessionContentProvider] listSessions took 174344.89579900005ms
    2026-09-16 15:21:43.254 [info] [CopilotCLIChatSessionContentProvider] listSessions took 174024.20444200002ms
    
  4. removed
    bug
    on Sep 23, 2026
  5. alexdima commented on Nov 10, 2026

    @alexdima
    Member

    Thanks for the detailed analysis. This should be fixed on current Insiders. #345095 changed the Copilot CLI provider so a refresh lists only session ids and times, and drops sessions created outside VS Code (and ones the agent host already owns) before reading anything else. Details are cached per session by modified time, and the 5 s full re-walk is gone.

    What I checked on Insiders 1.146.0 (macOS arm64), with COPILOT_HOME pointing at a store of 6,000 CLI sessions created by github/cli over 20 days:

    • Opening the Agents window: the extension-host listSessions took was 1.7 s once at startup, then 120 ms on the next refresh. There were no repeated walks while a session was active.
    • Agent host side: discovery classified all 6,000 sessions in about 3 s and published the last 7 days of them in the background.
    • While a session ran and finished, typing in the composer stayed responsive. I saw no input lag and no "extension host unresponsive".

    I tested on macOS rather than Windows, but the change isn't platform-specific. If you still see long listSessions took times on a current Insiders, please reopen with the log lines. A retention or prune option for the CLI session store would be a separate feature request.

    i327021-6000-sessions.mp4

    🤖 Authored with GitHub Copilot on behalf of Alexandru Dima (@alexdima).

  6. added
    bug
    on Nov 10, 2026
  7. added this to the 1.147.0 milestone on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugperfverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions