Visual Studio Code 1.141 Stable, released October 7, 2026, adds a cleanup editor for worktree-isolated agent sessions. If old sessions have left local worktrees on your disk, Chat: Open Worktree Cleanup shows eligible sessions and an estimated size for each worktree. You choose which ones to remove. This guide follows Microsoft's release notes and session-management documentation; BIG CHANGE did not run cleanup or measure storage savings.
Review the selected worktrees before confirming
- In VS Code 1.141, open the Command Palette and run
Chat: Open Worktree Cleanup. - Choose an inactivity filter: 7, 15, 30, 60 or 90 days. This determines which sessions appear as eligible; it is not an automatic deletion timer.
- Read each session and its estimated worktree size. Eligible worktrees are selected by default. Clear the selection for any session you want to keep, including work whose branch or files you have yet to inspect.
- Confirm cleanup only for the remaining selections.
VS Code marks each selected session as done and schedules its worktree for removal. Before removing a worktree, it commits uncommitted changes to that session's branch. If it cannot preserve the changes or remove the worktree, the worktree stays. The session and branch history remain available. Find the session through the Done filter in the Agents window (or Archived in Chat view) and restore it to recreate the worktree from the branch. The documentation describes this preservation behavior; it does not promise that every eligible worktree will be removed or a particular amount of disk space recovered.
The cleanup editor omits active, running, waiting-for-input and pinned sessions. It also omits done, archived, untitled and error-state sessions, sessions newer than the chosen threshold, and worktrees whose size VS Code cannot measure. A missing session in this editor therefore does not prove that its worktree is gone.
Keep cleanup separate from deleting a session
Manual worktree cleanup preserves the session and branch. Delete is a different action: VS Code's documentation says deleting a session is permanent and cannot be undone. For Copilot sessions it also removes associated worktrees, subject to shared-worktree behavior. The documentation warns that uncommitted files present only in a removed worktree can be lost. Use the cleanup editor for the documented recoverable worktree path, and inspect work you need before selecting it.
Suggestions and preview automatic cleanup
The optional chat.agentSessions.sessionStorageCleanupSuggestion.enabled setting shows an Agents window suggestion when inactive worktrees use at least 5 GiB or 20 worktrees are eligible. The suggestion opens the same review editor. It does not itself remove a worktree. You can dismiss a suggestion for the current window, choose Don't Show Again, or run Chat: Disable Session Storage Cleanup Suggestions.
VS Code also documents automatic session cleanup as a Preview feature. Its two settings are disabled by default. chat.agentSessions.autoMarkAsDoneMergedSessionsAfterDays sets the inactivity period before marking an eligible Agent Host session as done. chat.agentSessions.autoDeleteMarkedAsDoneMergedSessionsAfterDays sets a separate grace period before permanently deleting a session that VS Code marked as done automatically. Each accepts a positive whole number of days; 0 disables that stage. VS Code recommends 15 days, but this is a setting suggestion, not the manual editor's 7/15/30/60/90-day filter.
For preview automation, the session must be out of progress, past the configured last-modified threshold, associated with at least one merged pull request, and have no related open pull requests. External sessions are excluded. VS Code checks at startup and hourly while a setting is enabled. A session you marked as done yourself is not automatically deleted through this path; restoring an automatically completed session clears its deletion eligibility. For automatic cleanup to remove a worktree, its branch must track an upstream and have no outgoing commits or uncommitted changes. Unknown Git state or a failed condition leaves the worktree in place. VS Code says this process never force-removes one.
The manual editor is the relevant route when you want to inspect sizes and select old worktrees yourself. The preview settings concern a narrower merged-PR lifecycle and can eventually delete eligible sessions. VS Code does not list a separate charge for the cleanup feature in these documents. The actual space recovered depends on the worktrees that qualify and are removed.
The big change
- Developers with worktree-isolated agent sessions can now see an estimated size for each eligible inactive worktree in VS Code 1.141 and choose which ones to clean up.
- Manual cleanup marks selected sessions as done, preserves their branch history and commits uncommitted changes before worktree removal. A failed preservation or removal leaves the worktree in place, and restoring the session recreates it.
- Eligible worktrees start selected. Review the list before confirming. VS Code excludes active, running, waiting-for-input and pinned sessions, but those safeguards do not tell you whether you still need an inactive session's work.
- Preview automatic cleanup follows separate merged-pull-request rules and can permanently delete sessions after a configured grace period. Its settings start disabled.
Sources & further reading
The VS Code 1.141 release notes establish when the cleanup editor reached Stable and describe its purpose. Microsoft's Manage agent sessions in VS Code documentation supplies the detailed filters, default selections, safeguards, restoration steps and separate Preview automation rules. Both documents are listed in the source module below.



