Repository navigation
Description
Environment
- VS Code stable 1.130.0
- Commit: 1b6a188
- OS: Windows
- Local Agent Host, Copilot CLI provider
Problem
Existing conversations are sometimes restored with 0 turns despite having substantial history. AgentService subsequently treats them as empty unsubscribed sessions and deletes them.
This has happened twice. A replacement session created to recover the first lost conversation was also deleted. This causes significant, repeated loss of work.
Evidence: second incident
On 2026-10-08, AgentService logged the following for the SAME session (identifier redacted):
17:16:25.398 Restored session with 31 turns
17:17:57.081 Restored session with 0 turns
17:22:42.391 GC: disposing empty unsubscribed session
The session then disappeared from the session list, including archived sessions.
Evidence: first incident
On 2026-10-06, a CAPI proxy change caused CopilotClient to restart while an existing session was being resumed.
The logs reported:
SDK resumeSession failed: code=-32097, message=Pending response rejected since connection got disposed
Failed to resume session for message lookup Pending response rejected since connection got disposed
A subsequent resume reported 0 turns in AgentService, although the CLI log reported retrieving 2010 events.
Later, AgentService logged:
GC: disposing empty unsubscribed session
The CLI log explicitly confirmed:
Deleted session directory
Deleted session:
Some conversation text remained in session-store.db, but the session directory and full accessible conversation/tool history were lost.
Relevant implementation
In the installed build:
- _maybeScheduleSessionGc schedules cleanup when in-memory state has no turns and no active turn.
- The cleanup delay is hard-coded to 30 seconds.
- _runSessionGc checks subscribers and in-memory turns/activeTurn, then calls disposeSession if the session appears empty.
This appears unsafe for previously persisted sessions whose history restoration failed or produced an incomplete in-memory state.
The cause of the second erroneous 0-turn restore is not yet established.
Reproduction pattern
Exact deterministic reproduction steps are not yet known.
Observed pattern:
- Work in a persistent Copilot CLI session with substantial history.
- Restart/reload VS Code or reopen/resume the session.
- An existing session is sometimes restored with 0 turns.
- Switch away/unsubscribe.
- Empty-session GC deletes the persisted session.
The first incident involved a client restart during resume.
Expected behavior
A transient restore failure or empty in-memory representation must NEVER cause deletion of existing persisted conversation data.
Please:
- Restrict automatic deletion to verified newly created empty sessions.
- Preserve existing sessions when restoration fails and show a retryable error.
- Provide a setting to disable destructive automatic cleanup.
- Consider recoverable deletion or backups.
Actual behavior
Existing conversations are automatically deleted after an erroneous 0-turn restore. Even a recovered replacement conversation was subsequently lost.
Privacy
Session identifiers, usernames, corporate server names, project paths, and conversation contents have been omitted. The excerpts above are sanitized local log evidence.
Activity
roblourens commentedon Oct 14, 2026
Very old VS Code version! Should be fixed in the latest
🤖 Thanks for the detailed report. The build commit you provided predates 4b28158, which restricts empty-session GC to never-used drafts and protects restored conversations even when they load zero turns. This addresses the destructive cleanup described here; it does not recover history already deleted. A cleanup-disable setting or recoverable deletion would be separate enhancements. The fix shipped in 1.133.0.