MemoryLake
Back to all articles
TutorialAugust 31, 2026·11 min read

How to Set Up Copilot Memory in VS Code (2026 Guide)

Copilot has a memory layer now, and if you have been treating it as the tool that forgets your codebase between conversations, that assumption is out of date. VS Code's documentation, updated on August 26, 2026, opens the topic like this: "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."

There are two catches, and both are worth knowing before you rely on any of it.

The first is that there are two memory systems, not one, and the docs are explicit that they are separate features: "Copilot Memory is in preview and is separate from the local memory tool described above." They differ in where they store, what they scope to, who writes them, whether they are on by default, and how they end.

The second is that one of them ends on a timer. Buried in a bullet list is the fact that changes how you should use it: "Automatically expired: memories are deleted after 28 days to avoid outdated information."

This guide covers what each system holds, how to turn on the parts you want, and what belongs somewhere that does not expire.

One boundary first. The symptom side of this — what it looks like when Copilot keeps re-learning your project — is covered in why GitHub Copilot forgets codebase context. That page predates the memory features described here, so read it for the symptoms and this one for the current mechanisms.

Why repository knowledge still goes missing

There are two systems, and they are not interchangeable

The memory tool is local and built into VS Code. The docs describe it as "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." It is currently in preview, controlled by the chat.tools.memory.enabled setting, and it has three scopes:

  • User at /memories/ — persists across sessions and across workspaces. For "preferences, patterns, frequently used commands."
  • Repository at /memories/repo/ — persists across sessions, workspace-scoped. For "codebase conventions, project structure, build commands."
  • Session at /memories/session/ — "No (cleared when chat ends)." For "task-specific context, in-progress plans."

Copilot Memory is the other one: "a GitHub-hosted memory system that lets Copilot learn and retain repository-specific insights as it works," shared "across multiple GitHub Copilot surfaces, including Copilot cloud agent, Copilot code review, and Copilot CLI." Repository-scoped only, written automatically by agents, and off by default.

Confusing the two is the most common reason people think memory is not working. The local tool is on by default; the hosted one is not.

The one that spans surfaces is opt-in twice

Copilot Memory "is turned off by default and must be enabled in your GitHub settings" — in personal Copilot settings for Copilot Pro or Pro+ users, or through organisation or enterprise policy settings for teams.

There is a second gate on the VS Code side if you want your repository memory backed by it: an experimental setting that is disabled by default, plus the requirement that "Copilot Memory must be enabled for the repository in your GitHub settings." And the failure is quiet: "If either condition isn't met, repository memory falls back to local file storage." Nothing errors. Your repository memory simply stays on your laptop, and the cross-surface behaviour you thought you switched on never happens.

Repository memories expire after 28 days

This is the fact to design around. Copilot Memory deletes memories after 28 days, and the stated reason is a good one — "to avoid outdated information." Paired with it is a genuinely unusual safeguard that deserves credit: memories are "verified before use," meaning "agents validate memories against the current codebase before applying them, preventing stale or incorrect information from affecting results." Very few memory systems check themselves against reality before acting.

But read the two together. A system that both validates against the code and expires on a four-week clock is optimised for recent operational insight — the build quirk, the flaky test, the pattern discovered during last week's review. It is not built to hold your architectural decision from March. Anything you need in six months has to live somewhere else, and the docs' own comparison table says as much by contrasting Copilot Memory's "Automatic (28 days)" expiration against the local tool's "Manual management."

Instructions and memory answer different questions

Instructions are what you require; memory is what the agent learned. Copilot supports a lot of the first kind: a single .github/copilot-instructions.md, one or more AGENTS.md files, organisation-level instructions defined at the GitHub org level, and — notably — a CLAUDE.md file "For compatibility with Claude Code and other Claude-based tools," read from the workspace root, the .claude folder, or your user home directory. File-based *.instructions.md files add glob scoping through an applyTo header, and their documented locations include .github/instructions and .claude/rules.

One property of that system matters here more than any other: "If you have multiple instruction files in your project, VS Code combines and adds them to the chat context, no specific order is guaranteed." Combined, not resolved by precedence. If two files disagree, nothing decides for you — which is a strong argument for keeping requirements few and unambiguous, and for not using instruction files as a filing cabinet for everything you know.

What people try

Turning on the memory tool and assuming that is Copilot Memory. The local tool is enabled by default and writes to your machine. The cross-surface system is a separate opt-in on GitHub.

Putting everything in .github/copilot-instructions.md. It works until it is long, and then it competes for context with a second AGENTS.md, an inherited CLAUDE.md, and whatever .instructions.md files matched — with no guaranteed order among them.

Expecting memory to enforce a rule. It will not. Instructions are what you require; memory is what was noticed. Anything that must hold every time belongs in a check that fails the build.

Discovering the 28-day expiry after it matters. The usual version: a decision recorded in week one, absent in week six, re-litigated in week seven.

Concluding Copilot has no memory at all. Understandable a few months ago, wrong today, and it leads people to rebuild by hand what two documented systems already do.

The Fix: Split What Must Hold From What Can Expire

The setup itself is short. Do it in this order.

Enable the memory tool if it is off. It is on by default, but confirm chat.tools.memory.enabled and then use it deliberately: user memory for cross-project preferences, repository memory for codebase facts, session memory for the plan you are working through right now. One detail worth remembering — "The first 200 lines are automatically loaded into the agent's context at the start of every session" for user memory. Keep the top of that file worth the space.

Enable Copilot Memory only if you want cross-surface learning. Personal Copilot settings for individuals, policy settings for organisations, plus the repository-level enablement and the VS Code experimental setting if you want repository memory backed by it. Then verify rather than assume, because the fallback to local storage is silent.

Give repository owners the review habit. Stored memories can be reviewed and deleted in Repository Settings > Copilot > Memory, and memories "can only be created by contributors with write access." Look at the list once a month; it is the fastest way to learn what your agents think your codebase is.

Keep required guidance in instructions, not memory. One always-on file, scoped .instructions.md files for the rest, and nothing in either that you would be upset to see ignored — because no ordering is guaranteed between them.

Then handle the part with a four-week clock on it. MemoryLake is a memory layer that sits outside any single tool, so the knowledge that has to outlive 28 days does. Setup is three steps.

Step 1: Create an API key

Sign in and create an API key. One credential across the tools you connect.

Creating a MemoryLake API key alongside Copilot's two memory systems
Creating a MemoryLake API key alongside Copilot's two memory systems

Step 2: Upload your first memories

Short entries, one claim each. Write here what Copilot Memory is explicitly not designed to keep:

Writing knowledge that must outlive a 28-day expiry into MemoryLake
Writing knowledge that must outlive a 28-day expiry into MemoryLake

Decisions with their reasons. "The API is versioned in the path because two mobile clients pin an old build." Repository memory will expire; the reason should not.

What was tried and rejected. The approach that looked right and failed, and how it failed. Nothing in either Copilot system has a field for a negative result.

Ownership and boundaries. Who owns which service, which directories are frozen, which team to ask. Facts about people, not about code, which means no amount of validating against the codebase will recover them.

Pointers outward. The dashboard, the incident log, the design doc — the context an agent cannot find by reading your repository.

Step 3: Connect your AI & agents

Connect what you use. MemoryLake is reachable over MCP and over an API, and VS Code supports MCP servers, so the same memory is available beside Copilot. Claude Code, Codex, Cursor, and Cline read the same memory too — which matters here because Copilot's instruction loader already reads CLAUDE.md and .claude/rules, so a mixed-tool team is the normal case rather than the exception.

Connecting VS Code, Copilot and other agents to one shared memory layer
Connecting VS Code, Copilot and other agents to one shared memory layer

Three honest limits. MemoryLake does not read or write /memories/ or Copilot Memory — there is no API for either store, which is why the review habit above is manual. It does not change instruction ordering; the "no specific order is guaranteed" behaviour is VS Code's. And memory is context, not enforcement — anything that must be true on every run belongs in CI.

What this changes in practice

The two systems stop being one blurry feature. You know which is local, which is hosted, and which one you actually enabled.

The expiry stops being a surprise. Four-week operational insight in Copilot Memory; durable reasoning somewhere with no timer.

Instruction files get shorter. Once knowledge has a home, requirements stop being padded with background.

Cross-surface actually works when you turn it on. Because you verified it rather than trusting a setting that fails back to local storage in silence.

Best practices for Copilot memory

Confirm which system you enabled. The local memory tool defaults on; Copilot Memory defaults off and needs GitHub-side enablement.

Treat the 28-day expiry as a design constraint. Put anything you will need next quarter outside it.

Read the repository memory list monthly. Repository Settings > Copilot > Memory. It is a mirror of what your agents believe.

Keep user memory's first 200 lines valuable. That is the part loaded into every session.

Use session scope for plans. /memories/session/ is cleared when the chat ends, which is what you want for in-progress work.

Do not stack instruction files hoping precedence saves you. No order is guaranteed; contradictions just both arrive.

Remember instructions do not reach inline suggestions. The docs state they "are not taken into account for inline suggestions as you type in the editor."

Check where user-level instructions are read from on Agent Host. The docs note it reads "harness-agnostic folders like ~/.copilot/instructions and ~/.claude/rules and not from VS Code profile user data" — the general trap is described in why agents ignore your instruction files.

Conclusion

Copilot's memory story in VS Code is two features with one name in casual conversation. The local memory tool is in preview, on by default, and split into user, repository, and session scopes, with the first 200 lines of user memory loaded into every session. Copilot Memory is in preview, off by default, GitHub-hosted, repository-scoped, written automatically by agents with write access, and shared across the cloud agent, code review, and the CLI. Its safeguards are real — memories are validated against the current codebase before use, which is more than most systems do.

And they are deleted after 28 days. That single line tells you what the system is for: recent, checkable operational insight, not institutional knowledge. Set both systems up on purpose, verify the cross-surface path instead of assuming it, keep requirements in instruction files knowing no ordering is guaranteed among them, and put the decisions, the rejected approaches, and the ownership facts in a layer with no expiry clock.

Do that and Copilot stops re-learning your codebase every month — and you can see for yourself what each layer is holding, which is the exercise in how to audit what your AI assistants actually remember.

Frequently asked questions

Does GitHub Copilot have memory now?

Yes, in two forms, both documented as previews. The local memory tool in VS Code lets agents "save and recall notes as they work," with user, repository, and session scopes, and it is enabled by default via chat.tools.memory.enabled. Copilot Memory is a separate, GitHub-hosted system that captures repository-specific insights automatically and is shared across Copilot cloud agent, Copilot code review, and Copilot CLI. It is off by default.

How long does Copilot Memory keep a memory?

28 days. The documentation lists automatic expiry as a property of the system: "memories are deleted after 28 days to avoid outdated information." The local memory tool has no automatic expiry — its comparison row reads "Manual management" — so anything you want to persist longer either lives in the local tool, in an instruction file, or outside Copilot entirely.

I enabled repository memory sharing and nothing changed. Why?

Most likely one of the two conditions is unmet. Backing repository memory with Copilot Memory requires an experimental VS Code setting that is disabled by default and Copilot Memory enabled for the repository in your GitHub settings. The docs state that "If either condition isn't met, repository memory falls back to local file storage" — with no error. Check both, then confirm behaviour rather than assuming it.

Who can create and delete Copilot Memory entries?

Agents create them automatically as they work, and the scope is limited: memories "are tied to a specific repository and can only be created by contributors with write access." On the review side, "Repository owners can review and delete stored memories in Repository Settings > Copilot > Memory." Provenance and review are the two things worth building a habit around — the general principle is in memory provenance explained.

Should I use instruction files or memory for coding standards?

Instruction files. Memory is what an agent noticed; instructions are what you require. Copilot supports .github/copilot-instructions.md, AGENTS.md, organisation-level instructions, a compatibility-read CLAUDE.md, and glob-scoped *.instructions.md files. One caveat to plan around: "If you have multiple instruction files in your project, VS Code combines and adds them to the chat context, no specific order is guaranteed," so keep requirements few and non-contradictory. If you are arriving from Claude Code, the file-level mapping is in how to migrate your CLAUDE.md to Copilot.

Does Copilot memory replace a memory layer?

Not for anything long-lived. The two Copilot systems are complementary by design — the docs recommend the local tool "for personal preferences and session-specific context in VS Code" and Copilot Memory "for repository knowledge that benefits all Copilot agents." Both are scoped to Copilot, one expires in 28 days, and neither has a place for why a decision was made or which approach your team abandoned. That is the layer described in what persistent memory is, and it is the part that has to outlive both previews.