ThisCalculator

Everyday

Back Up VS Code Agent Session History

Updated · Standard formula, shown below

Back Up VS Code Agent Session History

This guide shows you how to back up or migrate your Visual Studio Code agent session history—the conversation logs and context that Copilot Chat and other AI agents keep across sessions. You’ll learn where these files live, how to copy them safely, and how to restore them on a new machine or after a reinstall. No special tools are required, just a basic file explorer and a few minutes.

What You’ll Need

  • Access to your file system (Explorer on Windows, Finder on macOS, or a terminal)
  • Enough free space on a destination drive or cloud folder for the history files (usually a few MB to tens of MB)
  • Visual Studio Code installed on the target machine if you’re migrating

Step-by-Step

  1. Close Visual Studio Code. This ensures no files are locked or being written while you copy them. If you have unsaved work, save it first.
  2. Locate the user data folder. The exact path depends on your operating system:
    • Windows: %APPDATA%\Code\User (usually C:\Users\YourName\AppData\Roaming\Code\User)
    • macOS: ~/Library/Application Support/Code/User
    • Linux: ~/.config/Code/User
  3. Find the session history files. Inside the User folder, look for a subfolder named globalStorage. Agent session history is stored in the globalStorage folder, typically under a subfolder named after the extension (e.g., github.copilot-chat for Copilot Chat). Look for files or folders that contain terms like chat, session, history, or state. Common ones include chatHistory, sessionState, or a file like state.vscdb (SQLite database).
  4. Copy the entire globalStorage folder (or just the relevant subfolder). To be safe, copy the whole globalStorage folder to your backup location. If you only want the agent history, copy the specific extension folder (e.g., github.copilot-chat). Use your file explorer’s copy/paste or a command like cp -r on macOS/Linux.
  5. Store the backup in a safe place. Put the copied folder on an external drive, cloud storage (OneDrive, Google Drive, etc.), or a version control repository. Make sure the destination is not on the same disk as your system if you’re worried about disk failure.
  6. To migrate to a new machine: Install Visual Studio Code on the target machine, then close it. Copy the backup folder’s contents into the same location on the new machine (e.g., %APPDATA%\Code\User\globalStorage on Windows). Overwrite any existing files if prompted.
  7. Restart Visual Studio Code. Open the app and check that your agent session history appears in the chat panel. If it doesn’t, verify the folder structure matches the original—some extensions expect a specific subfolder name.

Common Mistakes

  • Copying the wrong folder. The history is not in the project folder or the VS Code installation folder. It’s always in the user data folder under globalStorage.
  • Copying while VS Code is running. This can lead to corrupted or incomplete files. Always close VS Code completely before copying.
  • Overwriting the wrong machine’s data. When migrating, be careful not to overwrite the new machine’s existing history if you want to keep it. Back up the target’s data first.
  • Ignoring the extension-specific subfolder. Some agents store history in a subfolder named after the extension ID. If you copy only the parent folder but not the subfolder, the history won’t be restored.

Tips

  • Use a version control system. If you’re comfortable with Git, you can keep your globalStorage folder in a private repository to track changes and roll back if needed.
  • Automate backups. Use a scheduled backup tool (like Windows File History or Time Machine) to include the user data folder regularly.
  • Check the file size. If the history is very large, you might want to compress it into a ZIP file before storing—right-click the folder and choose “Compressâ€� or use zip -r.
  • Know your extension. Different agents (Copilot Chat, Continue, Cline, etc.) store history differently. Check the extension’s documentation if you’re unsure which folder to copy.

Troubleshooting

  • History not showing after restore. First, ensure you copied the correct subfolder. If the extension uses a SQLite database (state.vscdb), the file might be locked if VS Code is running. Close VS Code and try again. Also, verify that the folder name matches exactly—case matters on Linux/macOS.
  • Corrupted history files. If the chat history appears but is unreadable or crashes VS Code, the copy may have been made while VS Code was running. Restore from an older backup, or delete the corrupted folder and let the extension recreate it.
  • Permission errors. On macOS, the Library folder is hidden. In Finder, press Cmd+Shift+G and type the path. On Linux, ensure you have read/write permissions to the .config folder.
  • History from a different extension version. If you upgraded the extension, the new version might expect a different format. In that case, the history may not be compatible. Check the extension’s release notes for migration steps.

Frequently Asked Questions

Where exactly is the session history stored?

It’s stored in the globalStorage folder under your VS Code user data directory. The exact subfolder depends on the extension, but it’s always under globalStorage.

Can I back up only the chat history, not the whole globalStorage?

Yes, you can copy only the subfolder belonging to the specific agent extension (e.g., github.copilot-chat). That’s usually enough.

Will my session history sync across devices if I use Settings Sync?

No, Settings Sync does not sync globalStorage by default. You need to manually copy the folder or use a third-party sync tool that includes hidden folders.

Is it safe to edit the history files?

No, the files are typically SQLite databases or JSON files that the extension manages. Editing them manually can corrupt the history. Use the extension’s export feature if available.

How often should I back up?

It depends on how much you value the history. If you use agents heavily, consider backing up after each major project or weekly.

Can I migrate history from VS Code to another editor like Cursor?

Only if the other editor uses the same folder structure and extension. Cursor, for example, uses a similar but separate folder. You might be able to copy the history if the extension IDs match, but it’s not guaranteed.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.