Repository navigation
agentHost: preserve account identity across discovery cache expiry - #346295
Merged
Aaron Munger (amunger) merged 3 commits intoNov 9, 2026
Merged
Aaron Munger (amunger) merged 3 commits into
Aaron Munger (amunger) merged 3 commits into
Conversation
Keep the tracking ID in the existing credential-scoped cell independently of endpoint and SKU freshness. Preserve identity on transient discovery failures while retaining authoritative replacement and invalidation behavior. Follow-up to #345691. Co-authored-by: Copilot <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Transient discovery-refresh failures can leave a rejected credential’s identity available after an in-flight 401/403 or discard a known tracking ID before telemetry capture.
2 open issues
What changed in this PR
This follow-up separates Copilot account identity from expiring discovery data so long-running Agent Host work can retain edit-survival telemetry attribution without extending endpoint or SKU freshness.
Changes:
- Stores the latest tracking ID separately on the credential-scoped cache cell.
- Updates identity publication and invalidation alongside discovery results.
- Adds regression coverage for expiry, refresh failures, account isolation, rejection, and lifecycle cleanup.
| File | Description |
|---|---|
src/vs/platform/agentHost/test/node/shared/copilotApiService.test.ts |
Expands tests for identity retention, replacement, and invalidation. |
src/vs/platform/agentHost/node/shared/copilotApiService.ts |
Separates tracking-ID retention from discovery-cache freshness. |
Review effort: Balanced
Keep the last published CAPI client separately from expiring discovery data so delayed credential rejection invalidates the correct account context without clearing newer discovery. Retain known identity even before a telemetry reader is captured. Co-authored-by: Copilot <[email protected]>
Bring in the corrected CodeQL workflow while preserving the account identity cache changes and regression coverage. Co-authored-by: Copilot <[email protected]>
Aaron Munger (amunger)
marked this pull request as ready for review
November 9, 2026 22:17
Benjamin Christopher Simmonds (benibenj)
approved these changes
Nov 9, 2026
Aaron Munger (amunger)
deleted the
agents/can-you-implement-the-fix-and-manually-test
branch
November 9, 2026 22:19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Follow-up to #345691 and microsoft/vscode-internalbacklog#10569.
What and why
Keep a known Copilot account tracking ID available during long-running Agent Host work after endpoint/SKU discovery expires.
Previously,
captureCopilotTelemetryContextread identity through the same 30-minute freshness check as routing and SKU data. A file tool starting after that boundary could capture no identity even though the same account was still authenticated; refreshing discovery later could restore the ID for turn completion without repairing the edit's earlier snapshot.Store the most recently published tracking ID on the existing credential-scoped cache cell, independently of the expiring discovery value. Expiry and transient refresh failures can now omit stale SKU without dropping known identity, including before the first telemetry reader is captured. Successful discovery replaces or clears the identity, and explicit credential invalidation, endpoint changes, and disposal still clear it. Existing account-generation guards remain authoritative.
Retain the last published CAPI client separately so a deferred 401/403 can invalidate the correct credential context even after a transient refresh failure clears the discovery value. Rejection from an older client cannot invalidate a newer published discovery.
This does not extend endpoint/entitlement freshness or introduce extra discovery requests. Identity that has never been discovered remains unavailable.
Validation
135 passing. Covers expiry, transient failure/recovery, credential rejection, account isolation, endpoint changes, disposal, missing identity, competing discovery refreshes, deferred rejection ordering, and refresh failures before the first telemetry reader.
Manually tested the full Code OSS Agents build with a copied authenticated profile and a scratch Git repository. Temporarily shortened the cache TTL to 2 seconds and refresh buffer to 1 second, and used a local boolean-only probe to confirm that the cache was expired at actual file-tool execution.
Three real file-edit turns retained tracking identity while omitting expired SKU. Two real
hashChangereporting windows carried IDs matching the originating discovery and turn-completion records. No synthetic telemetry or identity was injected.All temporary timing changes and probes were removed, normal constants restored, and tests rerun before publication. The manual single-account run predates the deferred-rejection and pre-first-reader follow-ups; those scenarios and live multi-account/rejection boundaries are covered by automated regression tests rather than a repeat manual run. Deployed telemetry ingestion remains a post-rollout check.