Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To clear old Visual Studio Code agent sessions safely, first inspect them in the sessions list, then archive or mark done if you want to keep their history. Use Chat: Open Worktree Cleanup to review and remove eligible inactive worktrees. Permanently delete a session only after you have checked its changes and decided you no longer need its local or synced history.

Find sessions and check what they contain

A VS Code agent session groups a workspace, code changes, and one or more chats. The sessions list shows each session’s status, type, and file changes, which helps distinguish an inactive conversation from work that may still contain useful changes. See Microsoft’s Manage agent sessions in VS Code.

Before cleaning up, open the sessions list and review the candidates. Do not assume a session is safe to remove just because it is old: its status, worktree, and changes matter.

Choose the right cleanup action

Action What it does When to use it
Close a chat tab Hides the chat from the chat area; does not delete the conversation. When you only want to clear the current chat view.
Archive or mark a session done Removes it from the active list while retaining its session history. When the work is inactive but you may need its title, transcript, or history later.
Delete a session Permanently removes the session; Microsoft warns that “Deleting a session is irreversible.” Only when you intend permanent removal and have checked any work or history you need.

Pinning, archiving, or marking a session done can organize the list without destroying its history. For worktree sessions, archiving or marking done may commit uncommitted changes to the session branch before removing the worktree. If VS Code cannot preserve the changes or remove the worktree, the worktree remains; the branch and commits are preserved.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remove inactive worktrees with the cleanup editor

Worktrees can occupy disk space separately from ordinary chat history. To review eligible worktrees, open the Command Palette and run Chat: Open Worktree Cleanup. The editor lets you set an inactivity threshold, review estimated sizes, and decide which worktrees to keep.

  1. Open the Command Palette and run Chat: Open Worktree Cleanup.
  2. Choose an inactivity threshold: 7, 15, 30, 60, or 90 days.
  3. Review the estimated size shown for each listed worktree.
  4. Deselect any worktree you want to keep, then confirm the cleanup.

Cleanup selects eligible worktrees by default, marks the selected sessions done, and schedules worktree removal. Before removal, VS Code attempts to commit uncommitted changes to the session branch. If it cannot preserve the changes or remove the worktree, that worktree remains. The session and branch history are retained, so restoring the session can recreate the worktree.

Why an old session might not appear

The cleanup editor excludes sessions that are active, running, waiting for input, pinned, already done, archived, untitled, or in an error state. It also excludes sessions newer than the chosen inactivity threshold and worktrees whose size cannot be measured. Age by itself does not make a session eligible.

Protect changes before cleanup

VS Code tries to preserve uncommitted changes, but do not rely on cleanup as your only safeguard. Commit or integrate important work before removing a worktree. Files that exist only in a removed worktree can be lost if they are not preserved.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Delete synced session data separately

If Copilot session sync is enabled, removing local data and removing cloud data are separate choices. In the Command Palette, run Delete Session Sync Data, select the sessions, and choose the deletion scope:

  • Delete from local and cloud: removes the selected data from the machine and GitHub.com; this cannot be undone.
  • Delete from cloud only: removes the cloud copy while retaining the local copy.

Turning off chat.sessionSync.enabled keeps session data local going forward. It does not delete sessions already synced to GitHub.com; delete those using the command and scope that match your intent. See Microsoft’s session sync documentation.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Understand automatic cleanup settings

VS Code’s settings reference describes automatic cleanup of merged sessions as preview functionality that may change before general availability. The auto-mark-done and auto-delete settings are disabled by default; the documented recommended period is 15 days for each configured period. Automatic deletion applies only to sessions that VS Code automatically marked done, not sessions you marked done manually. See the Copilot settings reference.

An experimental cleanup suggestion may appear when inactive worktrees use at least 5 GiB or when 20 worktrees are eligible. The setting that enables the suggestion defaults to false. These are documented product thresholds, not guarantees that a particular session will be eligible.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.