Skip to content
This repository was archived by the owner on May 20, 2026. It is now read-only.

Enable BYOK for Business/Enterprise users with client_byok policy#5047

Closed
pierceboggan wants to merge 2 commits into
mainfrom
pierceboggan/byok-biz-enterprise-policy
Closed

Enable BYOK for Business/Enterprise users with client_byok policy#5047
pierceboggan wants to merge 2 commits into
mainfrom
pierceboggan/byok-biz-enterprise-policy

Conversation

@pierceboggan
Copy link
Copy Markdown
Contributor

Summary

Enables BYOK (Bring Your Own Key) model configuration for Business and Enterprise SKU users whose organization has the BYOK policy enabled.

Changes

1. copilotToken. Read client_byok claimts

  • Added isClientBYOKEnabled() method to CopilotToken that checks for client_byok=1 in the token claims
  • This claim is set server-side only for Business/Enterprise orgs that have the BYOK policy enabled

2. contextKeys.contribution. Set context key for VS Code corets

  • Sets github.copilot.clientByokEnabled context key based on isClientBYOKEnabled()
  • VS Code core reads this key to show the "Add Models" button in the model picker

Behavior

  1. Only affects Business and Enterprise SKU the client_byok=1 claim is only present in Copilot tokens for these plans when the BYOK policy is enabledusers
  2. Users will only be able to use BYOK if the BYOK policy is controlled server-side by the organization adminenabled
  3. Availability in other plans is Free, Pro, and other plan users are unaffectedunchanged

Companion PR

pierceboggan and others added 2 commits April 1, 2026 13:26
Add isClientBYOKEnabled() to CopilotToken that checks for the
client_byok=1 token value. Update isBYOKEnabled() to also allow
BYOK when this policy flag is set, enabling business and enterprise
users whose org has the client_byok policy enabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Set 'github.copilot.clientByokEnabled' context key from the copilot
token's client_byok flag. VS Code core reads this context key in
chatEntitlementService to ungate the 'Add Models' button for
business/enterprise users whose org has the client_byok policy.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 8, 2026 16:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables BYOK (Bring Your Own Key) availability for Business/Enterprise users when the server-minted Copilot token includes a client_byok=1 flag, and surfaces this state to VS Code core via a new context key.

Changes:

  • Added CopilotToken.isClientBYOKEnabled() to read the client_byok token field.
  • Updated BYOK gating logic to allow BYOK when client_byok=1 (still disabled on GHE).
  • Added a github.copilot.clientByokEnabled context key update path and unit tests covering the new BYOK gating behavior.
Show a summary per file
File Description
src/platform/authentication/common/copilotToken.ts Adds a helper to detect client_byok=1 from the token fields.
src/extension/contextKeys/vscode-node/contextKeys.contribution.ts Introduces and updates a new context key (github.copilot.clientByokEnabled) for VS Code core UI enablement.
src/extension/byok/common/byokProvider.ts Expands BYOK eligibility to include tokens with client_byok=1 (dotcom-only).
src/extension/byok/common/test/byokProvider.spec.ts Adds unit coverage for BYOK enablement across individual/business + dotcom/GHE scenarios.

Copilot's findings

  • Files reviewed: 4/4 changed files
  • Comments generated: 1

Comment on lines +201 to +208
private async _updateClientByokEnabledContext() {
try {
const copilotToken = await this._authenticationService.getCopilotToken();
commands.executeCommand('setContext', clientByokEnabledContextKey, copilotToken.isClientBYOKEnabled());
} catch (e) {
commands.executeCommand('setContext', clientByokEnabledContextKey, undefined);
}
}
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

github.copilot.clientByokEnabled is only updated via _onAuthenticationChange(). On initial activation, ContextKeysContribution starts this._inspectContext() before registering onDidAuthenticationChange, so the first token-mint event can be missed and this context key may remain unset until a later auth refresh. Consider also updating this key during startup (e.g., call _updateClientByokEnabledContext() from the constructor after listener registration, and/or set it after the successful getCopilotToken() in _inspectContext()).

Copilot uses AI. Check for mistakes.
@lramos15 lramos15 self-requested a review April 8, 2026 18:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants