Skip to content

copilot_chat: Add capability token exchange for GitHub Copilot - #49962

Closed
dastrobu wants to merge 1 commit into
zed-industries:mainfrom
dastrobu:experiment/gh-copilot-vscode-impersonation
Closed

dastrobu wants to merge 1 commit into
zed-industries:mainfrom
dastrobu:experiment/gh-copilot-vscode-impersonation

Conversation

@dastrobu

@dastrobu dastrobu commented Feb 24, 2026 •

Copy link
Copy Markdown
Contributor

Implements proper capability token exchange to enable access to all GitHub Copilot models including GPT-5.3-Codex and preview features.

Previously, Zed sent OAuth tokens directly to Copilot APIs, causing GitHub to filter out preview models. Now exchanges OAuth tokens for capability tokens that include feature flags like editor_preview_features=1.

Changes:

  • Add CapabilityToken struct with expiration tracking
  • Implement refresh_capability_token() with caching and auto-refresh
  • Update all API calls to use capability tokens instead of OAuth tokens
  • Add Copilot-Integration-Id: vscode-chat header
  • Fix GitHub Enterprise support with /api/v3/ path prefix
  • Clear capability tokens when OAuth token or configuration changes

Closes #49691

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Feb 24, 2026
Implements proper capability token exchange to enable access to all
GitHub Copilot models and preview features.

Previously, Zed sent OAuth tokens directly to Copilot APIs, causing
GitHub to filter out preview models. Now exchanges OAuth tokens for
capability tokens that include feature flags like
editor_preview_features=1.

Changes:
- Add CapabilityToken struct with expiration tracking
- Implement refresh_capability_token() with caching and auto-refresh
- Update all API calls to use capability tokens instead of OAuth tokens
- Add Copilot-Integration-Id: vscode-chat header
- Fix GitHub Enterprise support with /api/v3/ path prefix
- Clear capability tokens when OAuth token or configuration changes

Fixes zed-industries#49691

@benbrandt benbrandt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can't use the vscode-chat integration id

@benbrandt benbrandt closed this Mar 3, 2026
@dastrobu

dastrobu commented Mar 3, 2026

Copy link
Copy Markdown
Contributor Author

@benbrandt of course you can't use vscode. That is exactly what I was mentioning over in #49586 (comment):

What the PR shows, is that Zed really needs its own Copilot-Integration-Id, (currently set to vscode-chat) in the draft).
@benbrandt maybe you can take a look at the draft and take it as inspiration for the real fix.
I am also here to help bringing this forward.

That is why this was opened as draft PR to show how API calls could work if there would be zed Copilot-Integration-Id.
Did I misunderstand the purpose of drat PRs in this project?

@yeskunall

Copy link
Copy Markdown
Contributor

Did I misunderstand the purpose of drat PRs in this project?

Nope, but Ben might have missed your comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot models unavailable

3 participants