Skip to content

Fix client-side Copilot token handling and add tests - #331737

Merged
SteVen Batten (sbatten) merged 2 commits into
mainfrom
sbatten/agents/client-side-copilot-token-fixes-a26d0eed
Aug 20, 2026
Merged

Fix client-side Copilot token handling and add tests#331737
SteVen Batten (sbatten) merged 2 commits into
mainfrom
sbatten/agents/client-side-copilot-token-fixes-a26d0eed

Conversation

@sbatten

Copy link
Copy Markdown
Member

This pull request addresses two critical client-side failures related to the Copilot token refresh mechanism, specifically during outage scenarios. The changes include:

  • Enhanced the FetchedValue utility to manage failure retry windows and prioritize Retry-After handling.
  • Migrated the completions token cache to utilize FetchedValue, implementing a five-second cooldown for ordinary failures.
  • Propagated HTTP 429 responses and Retry-After metadata through the token minting process.
  • Prevented alternating-error retry loops by removing error-message changes as triggers for token change events.
  • Added comprehensive regression tests to ensure the reliability of the new behavior.

The implementation focuses on maintaining a compact codebase while effectively addressing the identified issues, with a total of 304 lines added, primarily for tests. All validation checks have passed successfully.

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.

Pull request overview

Improves Copilot token refresh resilience during outages and rate limiting.

Changes:

  • Adds retry-window and invalidation support to FetchedValue.
  • Propagates rate-limit metadata and applies bounded backoff.
  • Migrates completion token caching and adds regression coverage.
Show a summary per file
File Description
shared-fetch-utils/common/test/fetchedValue.spec.ts Tests retry and invalidation behavior.
shared-fetch-utils/common/middleware/rateLimitBackoffMiddleware.ts Exposes shared backoff constants and header parsing.
shared-fetch-utils/common/fetchedValue.ts Adds failure cooldowns and generation-safe invalidation.
platform/authentication/vscode-node/copilotTokenManager.ts Converts rate limits into bounded blocked-fetch errors.
platform/authentication/test/node/copilotToken.spec.ts Tests HTTP 429 metadata propagation.
platform/authentication/test/node/authentication.spec.ts Tests token-change event semantics.
platform/authentication/node/copilotTokenManager.ts Parses and propagates retry metadata.
platform/authentication/common/copilotToken.ts Extends token errors with retry timing.
platform/authentication/common/authentication.ts Stops events caused only by changing errors.
completions-core/.../auth/test/copilotTokenManager.spec.ts Tests completion token failure caching.
completions-core/.../auth/copilotTokenManager.ts Migrates completion token caching to FetchedValue.

Review details

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

  • Files reviewed: 11/11 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@sbatten
SteVen Batten (sbatten) marked this pull request as ready for review August 20, 2026 15:23
@sbatten
SteVen Batten (sbatten) merged commit 88d8741 into main Aug 20, 2026
27 checks passed
@sbatten
SteVen Batten (sbatten) deleted the sbatten/agents/client-side-copilot-token-fixes-a26d0eed branch August 20, 2026 15:23
@vs-code-engineering vs-code-engineering Bot added this to the 1.135.0 milestone Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants