You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Copilot Agent Host sessions take ~60 seconds to appear after restart with a large ~/.copilot catalog #331155
After restarting VS Code Insiders (1.134.0-insider, commit fc62850), Copilot sessions in the Agents window take ~60 seconds to appear. Local harness sessions appear immediately.
Reproduction
Machine has ~1,207 SDK sessions under ~/.copilot/session-state and 1,373 Agent Host session databases.
Trace from agenthost.log
09:09:44 – Copilot provider registers, begins "Listing discoverable chats"
09:09:45 – 9 concurrent listSessions() calls arrive from restored windows
09:09:54 – Copilot SDK returns 1,207 sessions
09:10:30 – _discoverCopilotChats() classification finishes (0 external, 117 adoptable legacy, 1090 already known)
09:10:45 – first live listSessions() returns 47 sessions (~60 s after startup)
During classification ~1,957 session database opens and then ~2,296 more during the first live list.
Cause
_awaitInitialProviderMigration() in AgentService.listSessions() waits for the provider discovery promise before returning. The Copilot discovery pass introduced by #331082 enumerates the entire SDK catalog (~1,207 entries on this machine), classifying each one by opening its session database. The 9 concurrent listSessions() calls from the 8 restored windows all queue behind this discovery pass, so no Copilot sessions are shown in any window until classification completes.
The persisted localAgentHost.cachedSessions.v2 cache contains the correct set of recent sessions and is shown immediately by other providers; Copilot sessions appear to be withheld or replaced by the live result rather than rendered from cache while discovery runs.
Version
VS Code Insiders 1.134.0-insider (commit fc62850c)
Christof Marti (@chrmarti) The full catalog scan should be a one-time migration pass. Once the provider is marked migrated, session listing should no longer wait for migration. Could you please retry with the latest VS Code Insiders build after allowing the initial migration to complete, restart once more, and confirm whether the subsequent startup still delays local or SDK sessions? If it does, please attach the new Agent Host log covering that subsequent restart.
10:56:23.137 — first list computation completes after 32 seconds.
10:56:45.482 — queued list requests return, approximately 54 seconds after the first request.
A subsequent listing takes another 10.7 seconds.
All 14 listSessions requests eventually succeed. This is a latency problem rather than a failed request.
Updated diagnosis
PR #329633 changed steady-state enumeration from a full provider catalog scan to:
Agent Host registry
→ resolve metadata for N registered sessions
The full SDK scan is intended only for initial registry backfill.
PR #331082 subsequently made Copilot external-session discovery start whenever Agent Service attaches its discovery listener:
SDK listSessions() over the complete ~/.copilot catalog
→ compare with the Agent Host registry
→ classify unknown sessions
The legacy migration setting is still respected when publishing or adopting legacy sessions, but it no longer prevents the SDK catalog scan.
In this log, legacy adoption is disabled and no external sessions are discovered, but all 1,281 SDK sessions are still enumerated and classified.
The registry-first follow-up optimizations avoid database reads for already-known sessions during discovery. However, discovery still begins with:
client.rpc.sessions.list({})
The external scan and normal registry hydration run concurrently during startup. Removing the external scan would eliminate that recurring catalog work, although other session hydration and restoration work may still contribute to startup latency.
The three related features
1. Extension-host Copilot session adoption
Intent: Allow sessions created by the old VS Code extension-host Copilot CLI implementation to be adopted by Agent Host.
Before #329633, normal Copilot listing already called SDK listSessions(). When legacy migration was enabled, that same result was also inspected for adoptable extension-host sessions.
Candidate discovery repeated during listing/restart.
Actual adoption happened once per session, on explicit open.
Once adopted, persisted Agent Host metadata prevented that session from being adopted again.
2. Agent Host session catalog and orchestration
Intent: Make Agent Host own session identity, lifecycle and enumeration through a durable registry in a dedicated orchestrator database.
After the one-time backfill:
0 full SDK listSessions() calls for normal listing
N getChatMetadata() calls for N registered Agent Host sessions
This avoids enumerating the complete shared SDK catalog just to find sessions already owned by Agent Host. Depending on the number of registered sessions and concurrent clients, the N individual resolutions may perform similarly or better than the previous bulk scan.
3. External Copilot session discovery
Intent: Surface sessions created outside Agent Host, such as standalone Copilot CLI or GitHub Copilot application sessions.
Because those applications do not update the Agent Host registry, discovery compares the SDK catalog with the registry.
PR #331082 made this discovery independent of legacy migration. Consequently, the complete SDK catalog is scanned during startup even when legacy migration is disabled.
The external-session visibility setting controls which discovered sessions are shown, but it does not currently prevent the discovery scan itself.
Preferred solution
Use two-stage discovery:
If neither external-session discovery nor legacy migration is needed, make no SDK session-catalog request.
Otherwise, request only lightweight session identities/basic metadata, for example:
client.rpc.sessions.list({metadataLimit: 0})
Compare those IDs with the Agent Host registry.
Remove already-registered sessions.
Apply age or other filters available from the lightweight result.
Fetch full metadata only for unknown candidates.
Classify and register eligible external or legacy sessions.
An ID-only API such as listNonEmptySessionIds() could also be considered, but its recent/non-empty/limited semantics must be compatible with exhaustive migration requirements.
Tactical fix
In Copilot Agent, skip catalog discovery when both features are disabled:
showExternalSessions === none
AND
migrateLegacyCopilotCli === false
Enabled → disabled: do not publish results that are no longer requested.
A skipped pass must not be memoized as permanently completed.
This tactical change removes the full SDK scan for users who want neither external nor legacy Copilot sessions, while the preferred solution reduces the cost when discovery is enabled.
Activity
agentHost: make startup session discovery registry-first (#331155)
agentHost: make startup session discovery registry-first (#331176)
agentHost: make startup session discovery registry-first (#331239)
chrmarti commentedon Aug 24, 2026
It still takes very long. The recording shows the window open at 12s, local sessions only show at 32s and SDK sessions at 1:41.
Screen.Recording.2026-08-24.at.10.31.36.AM.mov
3 remaining items
sandy081 commentedon Aug 27, 2026
Christof Marti (@chrmarti) The full catalog scan should be a one-time migration pass. Once the provider is marked migrated, session listing should no longer wait for migration. Could you please retry with the latest VS Code Insiders build after allowing the initial migration to complete, restart once more, and confirm whether the subsequent startup still delays local or SDK sessions? If it does, please attach the new Agent Host log covering that subsequent restart.
chrmarti commentedon Aug 28, 2026
Still seeing it, will send you the log.
sandy081 commentedon Aug 30, 2026
I analyzed the new Agent Host log from a subsequent restart. This confirms the delay is not caused by the one-time registry migration repeating.
Timeline
10:55:50.837— external Copilot discovery starts.10:55:51.057— firstlistSessionsrequest starts.10:55:57.012— SDK returns 1,281 sessions.10:56:18.743— discovery classification completes:10:56:23.137— first list computation completes after 32 seconds.10:56:45.482— queued list requests return, approximately 54 seconds after the first request.All 14
listSessionsrequests eventually succeed. This is a latency problem rather than a failed request.Updated diagnosis
PR #329633 changed steady-state enumeration from a full provider catalog scan to:
The full SDK scan is intended only for initial registry backfill.
PR #331082 subsequently made Copilot external-session discovery start whenever Agent Service attaches its discovery listener:
The legacy migration setting is still respected when publishing or adopting legacy sessions, but it no longer prevents the SDK catalog scan.
In this log, legacy adoption is disabled and no external sessions are discovered, but all 1,281 SDK sessions are still enumerated and classified.
The registry-first follow-up optimizations avoid database reads for already-known sessions during discovery. However, discovery still begins with:
The external scan and normal registry hydration run concurrently during startup. Removing the external scan would eliminate that recurring catalog work, although other session hydration and restoration work may still contribute to startup latency.
The three related features
1. Extension-host Copilot session adoption
Intent: Allow sessions created by the old VS Code extension-host Copilot CLI implementation to be adopted by Agent Host.
Before #329633, normal Copilot listing already called SDK
listSessions(). When legacy migration was enabled, that same result was also inspected for adoptable extension-host sessions.2. Agent Host session catalog and orchestration
Intent: Make Agent Host own session identity, lifecycle and enumeration through a durable registry in a dedicated orchestrator database.
After the one-time backfill:
This avoids enumerating the complete shared SDK catalog just to find sessions already owned by Agent Host. Depending on the number of registered sessions and concurrent clients, the N individual resolutions may perform similarly or better than the previous bulk scan.
3. External Copilot session discovery
Intent: Surface sessions created outside Agent Host, such as standalone Copilot CLI or GitHub Copilot application sessions.
Because those applications do not update the Agent Host registry, discovery compares the SDK catalog with the registry.
PR #331082 made this discovery independent of legacy migration. Consequently, the complete SDK catalog is scanned during startup even when legacy migration is disabled.
The external-session visibility setting controls which discovered sessions are shown, but it does not currently prevent the discovery scan itself.
Preferred solution
Use two-stage discovery:
If neither external-session discovery nor legacy migration is needed, make no SDK session-catalog request.
Otherwise, request only lightweight session identities/basic metadata, for example:
Compare those IDs with the Agent Host registry.
Remove already-registered sessions.
Apply age or other filters available from the lightweight result.
Fetch full metadata only for unknown candidates.
Classify and register eligible external or legacy sessions.
An ID-only API such as
listNonEmptySessionIds()could also be considered, but its recent/non-empty/limited semantics must be compatible with exhaustive migration requirements.Tactical fix
In Copilot Agent, skip catalog discovery when both features are disabled:
Conceptually:
The setting lifecycle must also be handled:
This tactical change removes the full SDK scan for users who want neither external nor legacy Copilot sessions, while the preferred solution reduces the cost when discovery is enabled.
benibenj commentedon Aug 31, 2026
Closing as many performance fixes have been made. If further performance issues exist, new logs should be captured as much has changed in the meantime