← 返回首页
Memory in VS Code agents

Documentation

Topics Overview Overview Linux macOS Windows VS Code for the Web Raspberry Pi Network Additional Components Uninstall VS Code Tutorial Copilot Quickstart User Interface Personalize VS Code Install Extensions Tips and Tricks Intro Videos Overview Setup Quickstart Overview Language Models Context Tools Agents Customization Trust & Safety Overview Agents Tutorial Agents Window Planning Memory Tools Subagents Local Agents Copilot CLI Cloud Agents Third-Party Agents Overview Chat Sessions Add Context Inline Chat Review Edits Checkpoints Artifacts Panel Debug Chat Interactions Prompt Examples Overview Instructions Prompt Files Custom Agents Agent Skills Language Models MCP Hooks Plugins Context Engineering Customize AI Test-Driven Development Edit Notebooks with AI Test with AI Test Web Apps with Browser Tools Debug with AI MCP Dev Guide OpenTelemetry Monitoring Inline Suggestions Smart Actions Best Practices Security Troubleshooting FAQ Cheat Sheet Settings Reference MCP Configuration Workspace Context Display Language Layout Keyboard Shortcuts Settings Settings Sync Extension Marketplace Extension Runtime Security Themes Profiles Overview Voice Interactions Command Line Interface Telemetry Basic Editing IntelliSense Code Navigation Refactoring Snippets Overview Multi-Root Workspaces Workspace Trust Tasks Debugging Debug Configuration Testing Port Forwarding Integrated Browser Overview Quickstart Staging & Committing Branches & Worktrees Repositories & Remotes Merge Conflicts Collaborate on GitHub Troubleshooting FAQ Getting Started Tutorial Terminal Basics Terminal Profiles Shell Integration Appearance Advanced Overview Enterprise Policies AI Settings Extensions Telemetry Updates Overview JavaScript JSON HTML Emmet CSS, SCSS and Less TypeScript Markdown PowerShell C++ Java PHP Python Julia R Ruby Rust Go T-SQL C# .NET Swift Working with JavaScript Node.js Tutorial Node.js Debugging Deploy Node.js Apps Browser Debugging Angular Tutorial React Tutorial Vue Tutorial Debugging Recipes Performance Profiling Extensions Tutorial Transpiling Editing Refactoring Debugging Quick Start Tutorial Run Python Code Editing Linting Formatting Debugging Environments Testing Python Interactive Django Tutorial FastAPI Tutorial Flask Tutorial Create Containers Deploy Python Apps Python in the Web Settings Reference Getting Started Navigate and Edit Refactoring Formatting and Linting Project Management Build Tools Run and Debug Testing Spring Boot Modernizing Java Apps Application Servers Deploy Java Apps GUI Applications Extensions FAQ Intro Videos GCC on Linux GCC on Windows GCC on Windows Subsystem for Linux Clang on macOS Microsoft C++ on Windows Build with CMake CMake Tools on Linux CMake Quick Start C++ Dev Tools for Copilot Editing and Navigating Debugging Configure Debugging Refactoring Settings Reference Configure IntelliSense Configure IntelliSense for Cross-Compiling FAQ Intro Videos Get Started Navigate and Edit IntelliCode Refactoring Formatting and Linting Project Management Build Tools Package Management Run and Debug Testing FAQ Overview Node.js Python ASP.NET Core Debug Docker Compose Registries Deploy to Azure Choose a Dev Environment Customize Develop with Kubernetes Tips and Tricks Overview Jupyter Notebooks Data Science Tutorial Python Interactive Data Wrangler Quick Start Data Wrangler PyTorch Support Azure Machine Learning Manage Jupyter Kernels Jupyter Notebooks on the Web Data Science in Microsoft Fabric Foundry Toolkit Overview Foundry Toolkit Copilot Tools Create Agents Models Playground Agent Builder Agent Inspector Evaluation Tool Catalog Fine-Tuning (Automated Setup) Fine-Tuning (Project Template) Model Conversion Tracing Profiling (Windows ML) FAQ File Structure Manual Model Conversion Manual Model Conversion on GPU Setup Environment Without Foundry Toolkit Template Project Migrating from Visualizer to Agent Inspector Overview Getting Started Resources View Deployment VS Code for the Web - Azure Containers Azure Kubernetes Service Kubernetes MongoDB Remote Debugging for Node.js Overview SSH Dev Containers Windows Subsystem for Linux GitHub Codespaces VS Code Server Tunnels SSH Tutorial WSL Tutorial Tips and Tricks FAQ Overview Tutorial Attach to Container Create Dev Container Advanced Containers devcontainer.json Dev Container CLI Tips and Tricks FAQ Default Keyboard Shortcuts Default Settings Substitution Variables Tasks Schema
Copy as Markdown

On this page there are 3 sections

Memory in VS Code agents

Agents in Visual Studio Code use memory to retain context across conversations. Rather than starting from scratch each session, agents recall your preferences, apply lessons from previous tasks, and build up knowledge about your codebase over time.

For background on how memory fits into the agent architecture, see Agents concepts.

This article explains how to use the memory tool in VS Code, how to manage memory files, and how Copilot Memory extends memory across your development workflow.

Memory tool

Note

The memory tool is currently in preview. You can enable or disable it with the github.copilot.chat.tools.memory.enabled Open in VS Code Open in VS Code Insiders setting.

The memory tool is a built-in agent tool that allows agents to save and recall notes as they work. You can also explicitly ask the agent to remember something. All data is stored locally on your machine. The memory tool is enabled by default.

Memory scopes

Each scope serves a different purpose, depending on how long the information should persist and where it applies.

Scope Path Persists across sessions Persists across workspaces Use for
User /memories/ Yes Yes Preferences, patterns, frequently used commands
Repository /memories/repo/ Yes No (workspace-scoped) Codebase conventions, project structure, build commands
Session /memories/session/ No (cleared when chat ends) No Task-specific context, in-progress plans

User memory

User memory persists across all workspaces and conversations. The first 200 lines are automatically loaded into the agent's context at the start of every session. Use user memory for general preferences and insights that apply regardless of which project you're working in.

For example, ask the agent to remember a coding preference:

Remember that this project uses the repository pattern for data access and all API endpoints require authentication

Session memory

Session memory is scoped to the current conversation and cleared when the conversation ends. Use session memory for temporary working notes or task-specific context that the agent tracks while working through a multi-step task.

The Plan agent uses session memory to persist its implementation plans in a plan.md file. This plan is available during the session and can be viewed with the Chat: Show Memory Files command, but is not available in subsequent sessions. Learn more about planning with agents.

Store and retrieve memories

To store a memory, ask the agent to remember something in natural language. The agent determines the appropriate scope and creates or updates the corresponding memory file.

What are our commit message conventions?

Memory file references in the agent's chat responses are clickable, so you can view the contents of the memory file directly.

Manage memory files

VS Code provides commands to view and manage your memory files:

  • Chat: Show Memory Files: opens a list of all memory files across scopes. Select a file to view its contents.
  • Chat: Clear All Memory Files: removes all memory files across all scopes.
Note

Deleting individual memory files is not yet supported. Use Chat: Clear All Memory Files to remove all memories, or ask the agent to update a specific memory file to remove outdated information.

Copilot Memory

Note

Copilot Memory is in preview and is separate from the local memory tool described above.

Copilot Memory is a GitHub-hosted memory system that lets Copilot learn and retain repository-specific insights as it works. Unlike the local memory tool, Copilot Memory is shared across multiple GitHub Copilot surfaces, including Copilot cloud agent, Copilot code review, and Copilot CLI.

How Copilot Memory works

As Copilot agents work in your repositories, they automatically capture tightly scoped insights called "memories". These memories are:

  • Repository-scoped: memories are tied to a specific repository and can only be created by contributors with write access.
  • Cross-agent: what one Copilot agent learns is available to other agents. For example, a pattern discovered by Copilot code review can later guide Copilot cloud agent.
  • Verified before use: agents validate memories against the current codebase before applying them, preventing stale or incorrect information from affecting results.
  • Automatically expired: memories are deleted after 28 days to avoid outdated information.

Enable Copilot Memory

Copilot Memory is turned off by default and must be enabled in your GitHub settings:

  • Individual users (Copilot Pro or Pro+): enable Copilot Memory in your personal Copilot settings on GitHub.
  • Organizations and enterprises: enable through policy settings in your organization or enterprise settings.

In addition, you need to enable Copilot Memory integration in VS Code with the github.copilot.chat.copilotMemory.enabled Open in VS Code Open in VS Code Insiders setting.

Repository owners can review and delete stored memories in Repository Settings > Copilot > Memory.

For detailed setup instructions, see Enabling and curating Copilot Memory in the GitHub documentation.

Memory tool vs. Copilot Memory

Memory tool Copilot Memory
Storage Local (on your machine) GitHub-hosted (remote)
Scopes User, repository, session Repository only
Shared across Copilot surfaces No (VS Code only) Yes (coding agent, code review, CLI)
Created by You or the agent during chat Copilot agents automatically
Enabled by default Yes No (opt-in)
Expiration Manual management Automatic (28 days)

The two systems are complementary. Use the local memory tool for personal preferences and session-specific context in VS Code. Use Copilot Memory for repository knowledge that benefits all Copilot agents across your development workflow.