Skip to content

fix(github-copilot): set Copilot-Integration-Id header to vscode-chat#36574

Open
zhy-1976 wants to merge 1 commit into
anomalyco:devfrom
zhy-1976:fix/copilot-integration-id
Open

fix(github-copilot): set Copilot-Integration-Id header to vscode-chat#36574
zhy-1976 wants to merge 1 commit into
anomalyco:devfrom
zhy-1976:fix/copilot-integration-id

Conversation

@zhy-1976

@zhy-1976 zhy-1976 commented Jul 12, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #36575

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Newer GitHub Copilot models (gpt-5.6-luna, gpt-5.6-sol, gpt-5.6-terra) return 403 Forbidden from the Copilot chat completions endpoint when used through opencode. Existing models (4.1, 5, 5.5, claude-*, etc.) keep working.

Why: when opencode omits the Copilot-Integration-Id request header, GitHub's Copilot API infers the integration id from the OAuth client id. opencode's OAuth CLIENT_ID (Ov23li8tweQw6odWQebz) is registered internally as copilot-language-server, and that integration is not authorized for the 5.6 model family.

Fix: explicitly send Copilot-Integration-Id: vscode-chat on every Copilot request, with an env override (OPENCODE_COPILOT_INTEGRATION_ID) for advanced users:

"Copilot-Integration-Id":
  process.env["OPENCODE_COPILOT_INTEGRATION_ID"] ?? "vscode-chat",

Two lines changed in packages/opencode/src/plugin/github-copilot/copilot.ts. No behavior change for models that already worked (they accept vscode-chat too).

How did you verify your code works?

Reproduced against the live Copilot API with curl using the same OAuth-refreshed bearer token, varying only the Copilot-Integration-Id header:

Copilot-Integration-Id 5.6 model (gpt-5.6-luna)
(header omitted) 403 (server infers copilot-language-server)
copilot-language-server 403
vscode-chat 200 OK

Existing models (gpt-4.1, gpt-5, gpt-5.5, claude-*) continue to return 200 with vscode-chat set, matching the behavior with the header omitted.

Screenshots / recordings

N/A (no UI change).

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

GitHub's Copilot API infers the integration id from the OAuth client id
when no Copilot-Integration-Id header is supplied. For opencode's OAuth
app, the inferred id maps to "copilot-language-server", which is
rejected (403) by newer models such as gpt-5.6-*.

Explicitly send Copilot-Integration-Id: vscode-chat so these models
work out of the box. Users can override via the
OPENCODE_COPILOT_INTEGRATION_ID environment variable.
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels Jul 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

GitHub Copilot 5.6 models (gpt-5.6-luna/sol/terra) return 403 Forbidden

1 participant