Skip to content

Harden Copilot completion context caching - #14747

Draft
Sean McManus (sean-mcmanus) wants to merge 2 commits into
mainfrom
seanmcm/devbox2-wsl/agent91/harden-copilot-context-cache
Draft

Harden Copilot completion context caching#14747
Sean McManus (sean-mcmanus) wants to merge 2 commits into
mainfrom
seanmcm/devbox2-wsl/agent91/harden-copilot-context-cache

Conversation

@sean-mcmanus

Copy link
Copy Markdown
Contributor

Summary

Ensures Copilot completion context cache entries are reused only when the caret distance and request options still match. It also invalidates shared cache state on C/C++ document and configuration changes and prevents in-flight computations from repopulating invalidated entries.

This PR was investigated and created by Copilot with GPT-5.6 Sol (in VS Code). Any message starting with ✨Copilot: was sent by Copilot.

Details

  • Associate cached results with the feature, count, length, and aggregation policy used to compute them.
  • Correct stale-distance evaluation and reject late results from an invalidated cache generation.
  • Clear shared cache and parameter state when relevant documents or configurations change.
  • Dispose registrations that complete after the provider has already been disposed.

Validation

  • TypeScript compilation
  • ESLint on the changed source and test files
  • All 219 extension unit tests

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are focused, internally consistent, and cover the identified cache and disposal scenarios with unit tests.

Pull request overview

Hardens Copilot completion-context caching against stale entries and late asynchronous results.

Changes:

  • Validates cache entries against caret distance and request policy.
  • Invalidates shared cache state on document/configuration changes.
  • Safely handles late provider registrations after disposal.
File summaries
File Description
Extension/src/LanguageServer/copilotCompletionContextCache.ts Adds generation-aware cache and disposable storage.
Extension/src/LanguageServer/copilotCompletionContextProvider.ts Integrates validation, invalidation, and safe disposal.
Extension/src/LanguageServer/client.ts Shares and clears the provider across clients.
Extension/test/unit/copilotCompletionContextCache.test.ts Tests cache validation, invalidation, and disposal.
Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Pull Request

Development

Successfully merging this pull request may close these issues.

2 participants