October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk3 min

How to Find and Remove Stale Visual Studio Code Agent Sessions Safely

Learn how to inspect old VS Code agent sessions, safely clean up worktrees, and distinguish archiving from irreversible deletion.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use VS Code’s sessions list to inspect old agent sessions, then archive or mark a session done if you want to keep its history. For reclaiming space used by worktrees, use Chat: Open Worktree Cleanup and review each candidate before confirming. Delete a session only after checking its changes: Microsoft warns that session deletion is irreversible.

What counts as a stale agent session?

A session is a unit of agent work that brings together a workspace, code changes, and one or more chats. The sessions list shows each session’s status, type, and file changes, so inspect those details rather than treating every old entry as disposable. See Microsoft’s Manage agent sessions in VS Code.

There are several different actions that can make a session less visible, and they do not have the same effect:

Action What it does Effect on history or work
Close a chat tab Hides the chat from the chat area. Does not delete the conversation.
Mark a supported chat done Removes it from the active list. Keeps its title and transcript.
Archive or mark a session done Moves the session out of the active list. Retains the session history; worktree handling may also preserve changes on the session branch.
Delete a session Permanently removes the session. Irreversible. Work isolated in a removed worktree can be lost if it has not been preserved.

How to inspect and safely tidy sessions

  1. Open the sessions list. Review the status, session type, and file changes for each candidate. Pinning, archiving, or marking a session done can organize the list without permanently deleting its history.
  2. Archive or mark done if you may need the session later. For a worktree session, VS Code may commit uncommitted changes to the session branch before removing the worktree. If it cannot preserve the changes or remove the worktree, the worktree remains; the branch and commits are preserved.
  3. Use the worktree cleanup editor to reclaim worktree storage. Open the Command Palette and run Chat: Open Worktree Cleanup. Choose an inactivity threshold—7, 15, 30, 60, or 90 days—then review the estimated size of each listed worktree. Deselect any worktree you want to keep before confirming.
  4. Commit or integrate important work before permanent deletion. VS Code tries to preserve uncommitted work during cleanup, but do not rely on that as your only safeguard. Files that exist only in a removed worktree can be lost.

Which worktrees appear in cleanup?

The cleanup editor selects eligible worktrees by default, marks their 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, it leaves the worktree in place. The session and branch history are preserved so restoring the session can recreate the worktree.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Age alone does not make a worktree eligible. The 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 selected threshold and worktrees whose size cannot be measured.

How to remove synced session data

Copilot session sync has a separate deletion choice for local and cloud data. In the Command Palette, run Delete Session Sync Data, select the sessions, and choose the deletion scope:

Rank #2
Sale
Samsung T7 Portable SSD 1TB Titan Gray, USB 3.2 Gen 2, Up to 1,050MB/s
  • MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
  • SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
  • ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
  • ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
  • HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³
  • Delete from local and cloud: removes the data from this machine and GitHub.com. This cannot be undone.
  • Delete from cloud only: removes the cloud copy while retaining the local copy.

To keep session data local going forward, disable chat.sessionSync.enabled. Turning sync off does not remove sessions already synced to GitHub.com; delete existing cloud copies separately. See Microsoft’s session sync documentation.

What automatic cleanup does—and does not do

The VS Code 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; Microsoft documents 15 days as the recommended value for each configured period. Automatic permanent deletion applies only to sessions VS Code automatically marked done, not sessions you marked done yourself. See the Copilot settings reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
Samsung T7 Portable SSD 2TB Titan Gray, USB 3.2 Gen 2, Up to 1,050MB/s
  • MADE FOR THE MAKERS: Create; Explore; Store; The T7 Portable SSD delivers fast speeds and durable features to back up any endeavor; Build your video editing empire, file your photographs or back up your blogs all in an instant
  • SHARE IDEAS IN A FLASH: Don’t waste a second waiting and spend more time doing; The T7 is embedded with PCIe NVMe technology that brings fast read and write speeds up to 1,050/1,000 MB/s¹, making it almost twice as fast as the T5
  • ALWAYS MAKE THE SAVE: Compact design with massive capacity; With capacities up to 4TB, save exactly what you need to your drive – from large working files to game data and everything in between
  • ADAPTS TO EVERY NEED: Whether using a PC or mobile phone, count on the T7 for extensive compatibility²; It’s a true team player when it comes to heavy-duty application usage or file-saving
  • HI RESOLUTION VIDEO RECORDING: Record Ultra High Resolution (4K 60fs) videos directly onto the T7 Portable SSD with your favorite camera or mobile devices; Supports iPhone 15 Pro Res 4K at 60fps video and more³

An experimental cleanup suggestion can appear when inactive worktrees use at least 5 GiB or when 20 worktrees are eligible. The setting that enables this suggestion defaults to false. These are documented product thresholds and defaults, not guarantees that a particular machine will show a prompt.

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

When should you delete rather than archive?

Archive or mark a session done to declutter while keeping its history. Use worktree cleanup when the goal is to remove eligible worktree folders and reclaim their storage, after reviewing the candidate list. Choose permanent session or synced-data deletion only when you intend to remove that data and have preserved any code you need.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
Bestseller No. 4
Lexar ES3 1TB Portable SSD Silver, USB 3.2 Gen 2 up to 1050MB/s
Lexar ES3 1TB Portable SSD Silver, USB 3.2 Gen 2 up to 1050MB/s
Note: Magsafe is not available in this version
$179.99
Best Value
Sandisk 2TB Extreme Portable SSD, Up to 1050MB/s, USB-C, USB 3.2 Gen 2, IP65 Water and Dust Resistance, Updated Firmware, External Solid State Drive, SDSSDE61-2T00-G25
  • Get NVMe solid state performance with up to 1050MB/s read and 1000MB/s write speeds in a portable, high-capacity drive(1) (Based on internal testing; performance may be lower depending on host device & other factors. 1MB=1,000,000 bytes.)
  • Up to 3-meter drop protection and IP65 water and dust resistance mean this tough drive can take a beating(3) (Previously rated for 2-meter drop protection and IP55 rating. Now qualified for the higher, stated specs.)
  • Use the handy carabiner loop to secure it to your belt loop or backpack for extra peace of mind.
  • Help keep private content private with the included password protection featuring 256‐bit AES hardware encryption.(3)
  • Easily manage files and automatically free up space with the SanDisk Memory Zone app.(5). Non-Operating Temperature -20°C to 85°C
Rank #4
Lexar ES3 1TB Portable SSD Silver, USB 3.2 Gen 2 up to 1050MB/s
  • Note: Magsafe is not available in this version
  • High-speed Data Transfer: Lexar external SSD ES3 supports USB 3.2 Gen 2 up to 1050MB/s read and 1000MB/s write to transfer files fast for more efficient work. (Performance may be lower if not supporting USB 3.2 Gen 2 on Mac and other systems)
  • Wide Compatibility: Lexar Portable SSD ES3 compatibility with iPhone 17 series (Not supported on iPhone 14 and older models), Android mobile devices, laptops, cameras, Xbox X|S, PS4, PS5, gaming console, and more
  • On The Go: Lexar external solid state drive ES3's thin, stylish, and durable design, weighs 42g and is only 10.5mm thick, making it smaller than a card and easily fits in your pocket. It comes with a Type-C cable for plug-and-play convenience
  • Data Safety First: Lexar SSD ES3 includes Lexar DataShieldTM 256-bit AES encryption software to protect files

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.