Repository navigation
fix: memory leak in chat participant disposal - #338230
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits intoSep 28, 2026
Merged
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Dmitriy Vasyura (dmitrivMS) merged 4 commits into
Conversation
# Conflicts: # src/vs/workbench/api/test/common/extHostChatAgents2.test.ts
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Variable-provider registrations still leak on the main thread after participant disposal.
Review effort: Balanced
Findings: 1
What changed in this PR
Fixes extension-host retention when chat participants are disposed.
Changes:
- Removes disposed agents and completion-command resources.
- Makes disposal idempotent and ignores late completions.
- Adds lifecycle regression tests.
| File | Description |
|---|---|
src/vs/workbench/api/common/extHostChatAgents2.ts |
Implements participant cleanup. |
src/vs/workbench/api/test/common/extHostChatAgents2.test.ts |
Tests disposal behavior. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 28, 2026
Collaborator
|
Simon Siefke (@SimonSiefke) Thank you! |
Dmitriy Vasyura (dmitrivMS)
enabled auto-merge (squash)
September 28, 2026 01:16
Martin Aeschlimann (aeschli)
approved these changes
Sep 28, 2026
Christof Marti (chrmarti)
approved these changes
Sep 28, 2026
Ladislau Szomoru (lszomoru)
approved these changes
Sep 28, 2026
Dmitriy Vasyura (dmitrivMS)
merged commit Sep 28, 2026
28c67b3
into
microsoft:main
36 of 38 checks passed
Simon Siefke (SimonSiefke)
deleted the
fix/memory-leak-chatParticipant-disposal
branch
September 29, 2026 11:15
Abdon Morales (abdonmorales)
pushed a commit
to abdonmorales/vscode-utcs
that referenced
this pull request
Oct 1, 2026
* fix: memory leak in chat participant disposal * fix: unregister completion providers on chat participant disposal --------- Co-authored-by: Dmitriy Vasyura <[email protected]> (cherry picked from commit 28c67b3)
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

Details
When an extension disposes a chat participant, its entry stays in the extension-host agent map. Its request handler and completion-command store are not removed.
Change
Remove the agent entry and dispose its completion commands when the participant is disposed. Make disposal idempotent and ignore completion results that finish afterward.
Before
Registering and disposing a chat participant 37 times adds 37 old agents, captured state objects, and request handlers.
After
No more participant or handler growth is detected in the same 37-cycle test. The agent map stays empty after disposal.
Test Video
Seven registration and disposal cycles through the extension API.
test.mp4
AI disclosure: Model: GPT 6 Astra. Worktime: 29 min