Repository navigation
agentHost: refresh discovery after account entitlement changes - #342104
Merged
Aaron Munger (amunger) merged 6 commits intoOct 19, 2026
Merged
Conversation
Revalidate token-scoped Copilot discovery when a matching workbench account observes a new SKU without rotating credentials. Keep refresh work independent of credential acceptance and preserve account, issuer, and endpoint ownership. Refs microsoft/vscode-internalbacklog#10006 Co-authored-by: Copilot <[email protected]>
Contributor
|
Base:
|
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Concurrent cache writes can lose refreshed entitlements, and authentication forwarding and test coverage need correction.
4 open findings
What changed in this PR
Refreshes Agent Host’s cached Copilot entitlement when the workbench observes a same-account plan change, without trusting the client’s SKU.
Changes:
- Adds optional account-scoped entitlement metadata to authentication.
- Revalidates host discovery separately from credential acceptance.
- Adds metadata, forwarding, refresh, and revocation tests.
| File | Description |
|---|---|
| src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostAuth.test.ts | Tests hint forwarding and deduplication. |
| src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostAuth.ts | Attaches hints and preserves connector-session association. |
| src/vs/platform/agentHost/test/node/shared/copilotApiService.test.ts | Tests refresh isolation and failures. |
| src/vs/platform/agentHost/test/node/copilotAgent.test.ts | Tests agent refresh and nonblocking revocation. |
| src/vs/platform/agentHost/test/node/agentService.test.ts | Tests provider metadata forwarding. |
| src/vs/platform/agentHost/test/common/agentEntitlementMeta.test.ts | Tests metadata validation. |
| src/vs/platform/agentHost/node/shared/copilotApiService.ts | Adds account-verified discovery refresh. |
| src/vs/platform/agentHost/node/copilot/copilotAgent.ts | Starts background entitlement revalidation. |
| src/vs/platform/agentHost/node/agentHostAuthenticationService.ts | Forwards authentication metadata. |
| src/vs/platform/agentHost/common/meta/vscode/agentEntitlementMeta.ts | Defines and validates entitlement hints. |
| src/vs/platform/agentHost/common/meta/agentEntitlementMeta.ts | Exposes metadata helpers. |
| src/vs/platform/agentHost/common/agent.ts | Extends the provider authentication contract. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Prevent ordinary discovery from overwriting entitlement revalidation, preserve hints for connector and recovery authentication paths, and cover the actual agent refresh call. Register default-account state in remote-host authentication tests to restore browser and Electron CI. Co-authored-by: Copilot <[email protected]>
Record actual user-endpoint lookup results and cache publication outcomes to distinguish fresh responses from stale metadata. Include previous cache age and bounded HTTP tracing metadata without adding snapshot IDs or per-turn fields. Co-authored-by: Copilot <[email protected]>
Rename the account-scoped observation helpers and types to EntitlementHint while preserving the wire key. Use named forwarding parameter types and explicit provider/session checks instead of nested conditional expressions. Co-authored-by: Copilot <[email protected]>
Preserve entitlement-refresh coverage alongside upstream scoped-credential tests and retain both required imports in Claude tests. Co-authored-by: Copilot <[email protected]>
Aaron Munger (amunger)
marked this pull request as ready for review
October 19, 2026 18:21
Update the entitlement refresh PR to main at 4d22f4f without rewriting published history. Co-authored-by: Copilot <[email protected]>
Bhavya U (bhavyaus)
approved these changes
Oct 19, 2026
Aaron Munger (amunger)
deleted the
agents/draft-pr-code-review-implementation
branch
October 19, 2026 20:44
Elijah King (eli-w-king)
added a commit
that referenced
this pull request
Oct 19, 2026
Authentication forwarding reads the default account since #342104, which merged right after the Connector authorization tests in #342479, so those tests fail on main. Same change as #342706. Co-authored-by: Copilot <[email protected]>
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.


Agent Host can keep reporting an older Copilot entitlement after the workbench learns that the same account has gained access. For example, signing up for Copilot Free can leave successful requests labelled
no_accessuntil the host's independent discovery cache refreshes.Forward an optional, account-scoped entitlement hint through the existing authentication path when the observed SKU changes, even if the credential stays the same. The host verifies the analytics identity against its own discovery and re-fetches using its own credential; it does not accept the client's SKU as authoritative.
Revalidation runs separately from credential acceptance and normal cached discovery, so a slow refresh does not hold up same-token authentication or revocation. Same-account connector credentials retain the originating account-session association, and superseded endpoint contexts cannot initiate the new lookup.
Add one account-discovery telemetry event per actual user-endpoint lookup so fresh endpoint responses can be distinguished from stale or superseded cache metadata. It records returned account/SKU metadata, HTTP tracing information, outcome, duration, and previous cache age, without introducing discovery snapshot IDs or adding fields to turn/tool/SDK response events.
Related: microsoft/vscode-internalbacklog#10006.
To exercise the behavior, keep an Agent Host connected while refreshing the same account's entitlement after a plan change. Subsequent host telemetry should use the freshly discovered SKU without requiring token rotation or waiting for cache expiry. A different account's entitlement hint must not replace the host's metadata.
Live account/plan transitions have not been exercised locally.