Skip to content

agentHost: refresh discovery after account entitlement changes - #342104

Merged
Aaron Munger (amunger) merged 6 commits into
mainfrom
agents/draft-pr-code-review-implementation
Oct 19, 2026
Merged

Aaron Munger (amunger) merged 6 commits into
mainfrom
agents/draft-pr-code-review-implementation

Conversation

@amunger

@amunger Aaron Munger (amunger) commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

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_access until 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.

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]>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 16:17
@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Base: 4d22f4f9 Current: 6940f0fa

No screenshot changes.

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.

🟡 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]>
@amunger
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]>
@amunger
Aaron Munger (amunger) merged commit f7a95c3 into main Oct 19, 2026
49 checks passed
@amunger
Aaron Munger (amunger) deleted the agents/draft-pr-code-review-implementation branch October 19, 2026 20:44
@vs-code-engineering vs-code-engineering Bot added this to the 1.144.0 milestone Oct 19, 2026
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]>
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