Skip to content

Fix agent host Claude session deletion resurrection#325683

Open
wasteofwifi wants to merge 1 commit into
microsoft:mainfrom
wasteofwifi:main
Open

Fix agent host Claude session deletion resurrection#325683
wasteofwifi wants to merge 1 commit into
microsoft:mainfrom
wasteofwifi:main

Conversation

@wasteofwifi

@wasteofwifi wasteofwifi commented Jul 13, 2026

Copy link
Copy Markdown

Fix #325673: Delete Claude SDK transcripts when deleting agent sessions

Summary

Deleting a Claude agent-host session removed the VS Code session but left the underlying SDK transcript on disk, causing the session to reappear after a refresh.

This PR updates ClaudeAgent.disposeSession() to delete the SDK session before tearing down the in-memory wrapper, matching the existing behavior used by CopilotAgent and the transcript deletion flow in _removeAllTurns.

Testing

  • Verified materialized SDK sessions are deleted and no longer reappear after refresh.
  • Verified provisional sessions are skipped since no transcript exists.
  • Added regression tests covering transcript deletion and teardown ordering.

Copilot AI review requested due to automatic review settings July 13, 2026 19:34
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

@TylerLeonhardt

Matched files:

  • src/vs/platform/agentHost/node/claude/claudeAgent.ts

@wasteofwifi

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes agent-host Claude session deletion so it also removes the underlying Claude SDK transcript, preventing “deleted” sessions from reappearing on the next listSessions() refresh (overlay/metadata had been deleted, but the SDK transcript remained the source of truth).

Changes:

  • Update ClaudeAgent.disposeSession() to delete the SDK session (after awaiting live query teardown) when a durable transcript exists, including cold/unloaded sessions via getSessionInfo.
  • Clarify releaseSession() doc comment to reflect that disposeSession() now performs SDK-side deletion.
  • Update/add tests to cover the regression, ordering (await subprocess exit before delete), and to use releaseSession() where a non-destructive unload is intended.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/vs/platform/agentHost/node/claude/claudeAgent.ts Make disposeSession delete the SDK transcript (with proper ordering) and update releaseSession documentation.
src/vs/platform/agentHost/test/node/claudeAgent.test.ts Update stale expectations and add regression/race tests ensuring deletion prevents session resurrection and awaits teardown before deleting.

Comment on lines 1130 to 1142
return this._disposeSequencer.queue(sessionId, async () => {
const existing = this._findAnySession(sessionId);
if (existing) {
if (existing.isPipelineReady) {
await existing.shutdownLiveQuery();
await this._sdkService.deleteSession(sessionId);
}
} else if (await this._sdkService.getSessionInfo(sessionId)) {
await this._sdkService.deleteSession(sessionId);
}
await this._teardownEntry(sessionId);
this._pruneActiveClientHandles(sessionId);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent host: Delete... on a Claude session doesn't delete the SDK transcript — session resurrects on next list refresh

3 participants