Skip to content

V2: GitHub Copilot login and per-request headers not supported #34779

Description

@kitlangton

Summary

On the v2 branch, GitHub Copilot is catalog/SDK-only: there is no Copilot login method, and none of the required per-request headers / token handling that V1 injects. Copilot requests will not work correctly (and cannot authenticate via the Copilot OAuth flow).

Part of the systemic V2 provider-login gap (see #34765).

Evidence

  • packages/core/src/plugin/provider/github-copilot.ts only does a catalog tweak (hide gpt-5-chat-latest) and picks responses vs chat via shouldUseResponses. No ctx.integration.transform, no login method, no request-header injection, no Copilot token exchange.
  • Only openai and opencode register OAuth methods in packages/core/src/plugin/provider/.

How V1 does it (reference)

packages/opencode/src/plugin/github-copilot/copilot.ts:

  • Registers a GitHub OAuth device-code login; exchanges the GitHub token for a Copilot token.
  • Endpoint selection: https://api.githubcopilot.com (or https://copilot-api.<enterprise-domain> for enterprise).
  • loader custom fetch that, for OAuth credentials, on every request:
    • inspects the body to classify vision/agent requests,
    • sets Authorization: Bearer <copilot-token>, User-Agent: opencode/<version>, Openai-Intent: conversation-edits, x-initiator: agent|user, and Copilot-Vision-Request: true when images are present,
    • strips inbound x-api-key / authorization.
  • A chat.headers hook also sets X-GitHub-Api-Version, X-Interaction-Type, and anthropic-beta for Claude-via-Copilot models.

These headers are required by the Copilot backend; without them requests are rejected or mis-attributed.

What V2 needs

  1. Register the Copilot login method (GitHub OAuth device flow + Copilot token exchange/refresh) in github-copilot.ts.
  2. Request-time header injection: Authorization (Copilot token), Editor-Version/User-Agent, X-GitHub-Api-Version, Openai-Intent, x-initiator, and conditional Copilot-Vision-Request; strip inbound x-api-key/authorization.
  3. Correct base URL (api.githubcopilot.com / enterprise variant).

Some of this (vision/agent classification from the request body) is genuinely dynamic and needs the fetch/Auth.custom escape hatch, but the static headers and endpoint should go through the shared credential-aware request hook proposed in #34765 so both the AI SDK and native @opencode-ai/llm paths are covered.

Environment

  • Branch: v2
  • Status: verified against source; not runtime-reproduced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.0bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions