Use memory with agents in VS Code
Memory helps agents reuse coding preferences and repository knowledge without asking you to repeat them in every conversation. The memory system depends on your agent harness:
-
Copilot harness: Use Copilot Memory to store repository facts and user preferences in the cloud.
-
Local harness: Use memory files for persistent notes and temporary session context.
For background on how memory fits into the agent architecture, see Agents concepts.
This article shows how to set up cloud-backed memory, review or delete stored information, and manage local memory files.
Copilot Memory
Sessions that use the Copilot harness locally can use Copilot Memory, the same cloud memory service used by Copilot CLI, Copilot cloud agent, and code review. Memories captured by one supported feature can inform another, although supported scopes vary. For example, code review uses repository facts, not user preferences.
Set up cloud-backed memory
Copilot Memory is on by default in VS Code. To use it:
-
Sign in to GitHub Copilot with your GitHub account.
-
In your personal Copilot settings on GitHub, check that Copilot Memory is Enabled. If your plan is managed by an organization or enterprise, its policies must permit memory.
-
Check that chat.copilot.memory.enabled is on in VS Code Settings. If you previously turned it off, it stays off until you turn it on.
-
Create or resume a local Copilot session in the Chat view or Agents window. The setting applies to sessions created or resumed after it changes.
The VS Code editor preview-features policy doesn't control cloud memory.
Repository memories require a GitHub-hosted repository. User preferences are tied to your signed-in GitHub account and can apply across repositories.
If the setting is on but memory isn't available, check your GitHub account settings and organization policies. Contact your administrator if a required feature is unavailable or locked. For account eligibility and default billing-entity requirements when you have multiple licenses, see Managing Copilot Memory for your personal account.
Choose what to remember
Cloud-backed memory has two scopes:
| Scope | What it stores | Where it applies |
|---|---|---|
| Repository | Durable codebase facts and conventions, supported by citations to the code. | Shared with people who have access to the repository and Copilot Memory. Used only for that repository. |
| User | Coding and workflow preferences that apply across repositories. | Used in your own supported Copilot interactions, not other contributors' interactions. |
Storing repository facts requires write access to the repository and memory enabled for your account. On organization- or enterprise-managed plans, administrators can also review and delete user preferences. See Managing Copilot Memory for an organization or enterprise.
Don't store credentials, secrets, or sensitive personal information in memory. Repository facts are shared, not private notes. Keep reviewed team requirements in source-controlled project documentation or custom instructions.
Store, recall, and correct memories
Ask the agent to remember a durable convention or preference. State the scope when it matters:
Find how this repository verifies changes, and remember the command for this repository.
Across all my repositories, remember that I prefer concise commit message subjects.
The agent recalls relevant repository facts and user preferences when a session starts. It uses Store Memory to save new information. When it verifies an existing memory, it can upvote it instead of storing a duplicate. It can downvote an outdated memory and store a corrected replacement.
If a remembered convention is wrong, point the agent to the current code and ask it to correct the memory. Use persistent memory for durable information, not temporary task status.
Review and delete cloud memories
Review stored information on GitHub:
- User preferences: Open your personal memory settings to view and delete preferences.
- Repository facts: With repository administration access, open the repository's Settings > Copilot > Memory. Deleting a repository fact removes it for everyone who uses memory in that repository.
Asking the agent to forget a cloud memory downvotes it rather than permanently deleting it. To permanently delete it, use the GitHub settings above. The local memory-file commands below don't delete cloud memories.
Facts and preferences that go unused are automatically deleted after 28 days. Successful validation and use can reset that timer. Learn more about memory retention and validation.
To stop using cloud memory in newly created or resumed VS Code sessions, turn off chat.copilot.memory.enabled . Your personal memory setting on GitHub controls its use across supported Copilot features. To remove stored information, delete it on GitHub.
Local memory files
The Local harness has a separate file-based memory tool that saves and recalls notes as the agent works. You can also explicitly ask the agent to remember something. By default, user, repository, and session memory are stored locally on your machine.
The following sections describe local memory files. If repository memory is backed by GitHub instead, manage those repository facts on GitHub, not with the local file-management commands.
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 (current conversation only) | No | Task-specific context, in-progress plans |
Memory or shared project guidance
The memory files in this section are stored locally. Use them for personal preferences, temporary task context, or emerging project knowledge that your team hasn't reviewed. Repository memory files are associated with the current workspace, but aren't shared project files.
Put reviewed architecture decisions, commands, conventions, and workflows that contributors depend on in source-controlled project documentation or custom instructions. This makes the guidance available for your team's normal review and maintenance process.
When repository memory becomes stable and useful to the team:
- Verify the information against the repository's code and configuration.
- Move it to the appropriate project document or instructions file.
- Review the change through your repository's normal process.
- Update or remove the local memory to avoid stale or conflicting copies.
For a workflow that creates, verifies, and shares project instructions, see Configure AI for your codebase.
User memory
Local 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 I prefer a short summary before detailed code examples
In a later conversation, even in a different workspace, the agent recalls this preference and applies it to the response.
Repository memory
Repository memory is scoped to the current workspace and persists across conversations in that workspace. Use repository memory for facts about a specific codebase, such as architecture decisions, naming conventions, or build commands.
For example:
Remember that the legacy API routes in this workspace use the repository pattern for data access
Repository memory files are stored locally on your machine.
Session memory
Session memory is available only in the current conversation. 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 in the current conversation and can be viewed with the Chat: Show Memory Files command. 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.
Remember that I prefer concise commit message subjects
To retrieve a memory, ask about it in a new conversation. The agent checks its memory files and recalls the relevant information.
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 local memory files in Local harness sessions:
- 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.
To update or delete an individual memory file, ask the agent. Use Chat: Clear All Memory Files to remove all memory files.