Bug Description
When opening an old session in the Agents window, if the Copilot SDK rejects session.resume due to a validation error in the session file, the agent host silently falls back to createSession with the same ID. This results in the session appearing to load successfully but showing 0 turns — all conversation history is lost without any user-facing error.
Steps to Reproduce
- Have an existing agent session with conversation history
- The session file becomes corrupted (in this case, a compaction metadata field fails validation)
- Open the session in the Agents window
- Session appears empty — no error shown to user
Expected Behavior
The user should be informed that the session could not be restored due to corruption, rather than silently presenting an empty session.
Actual Behavior
The session loads with 0 turns. The user sees a blank conversation with no indication that data was lost.
Relevant Logs
[Copilot:df7c418f-...] _resumeSession called — session not in memory, resuming...
[Copilot:df7c418f-...] Calling SDK resumeSession...
[Copilot:df7c418f-...] SDK resumeSession failed: code=-32603, message=Request session.resume failed with message: Session file is corrupted (line 19567: data.compactionTokensUsed.copilotUsage.tokenDetails.0.batchSize: Number must be greater than 0)
[Copilot:df7c418f-...] Resume failed (code=-32603), falling back to createSession with same ID
[Copilot:df7c418f-...] Fallback createSession succeeded
[AgentHostStateManager] Restored session: copilotcli:/df7c418f-... (0 turns)
[AgentService] Restored session copilotcli:/df7c418f-... with 0 turns
Analysis
The fallback logic is in src/vs/platform/agentHost/node/copilot/copilotAgent.ts around line 1626:
if (!err || errCode !== -32603) {
throw err;
}
// Falls back to createSession with same ID
The comment says "The SDK fails to resume sessions that have no messages" — but error code -32603 is also returned for data corruption, not just empty sessions. The fallback does not distinguish between these cases.
Suggested Fix
Two potential approaches:
- Agent Host: Parse the error message to distinguish "no messages" from "corrupted" — surface a notification to the user when data is actually corrupted rather than silently creating an empty session
- SDK: The validation on
batchSize > 0 in compaction metadata should not prevent loading the actual conversation turns — this is metadata, not content
Bug Description
When opening an old session in the Agents window, if the Copilot SDK rejects
session.resumedue to a validation error in the session file, the agent host silently falls back tocreateSessionwith the same ID. This results in the session appearing to load successfully but showing 0 turns — all conversation history is lost without any user-facing error.Steps to Reproduce
Expected Behavior
The user should be informed that the session could not be restored due to corruption, rather than silently presenting an empty session.
Actual Behavior
The session loads with 0 turns. The user sees a blank conversation with no indication that data was lost.
Relevant Logs
Analysis
The fallback logic is in
src/vs/platform/agentHost/node/copilot/copilotAgent.tsaround line 1626:The comment says "The SDK fails to resume sessions that have no messages" — but error code
-32603is also returned for data corruption, not just empty sessions. The fallback does not distinguish between these cases.Suggested Fix
Two potential approaches:
batchSize > 0in compaction metadata should not prevent loading the actual conversation turns — this is metadata, not content