Fix agent host Claude session deletion resurrection#325683
Open
wasteofwifi wants to merge 1 commit into
Open
Conversation
Contributor
📬 CODENOTIFYThe following users are being notified based on files changed in this PR: @TylerLeonhardtMatched files:
|
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
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 viagetSessionInfo. - Clarify
releaseSession()doc comment to reflect thatdisposeSession()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); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 byCopilotAgentand the transcript deletion flow in_removeAllTurns.Testing