Description
The GitHub Copilot LLM driver does not work with any standard GitHub token type. The code says it exchanges a GitHub PAT for a Copilot API token, but the copilot_internal/v2/token endpoint rejects all standard token types:
- Classic PATs (ghp_) - 403 Forbidden
- Fine-grained PATs (github_pat_) with Copilot permission - 403 Forbidden
- gh CLI OAuth tokens (gho_) with copilot scope - 404 Not Found
The only token type that works is a ghu_ token obtained via the OAuth device flow using the VS Code Copilot extension's client ID (Iv1.b507a08c87ecfe98). There is no way for users to generate this through the GitHub website or standard tooling.
Reproduction
- Install OpenFang, configure github-copilot provider with any standard token
- Any chat or message attempt fails with 403 or 404 on token exchange
Working workaround
Manually run the OAuth device flow:
curl -s -X POST -H "Accept: application/json" \
-d "client_id=Iv1.b507a08c87ecfe98&scope=copilot" \
https://github.com/login/device/code
# authorize at github.com/login/device
curl -s -X POST -H "Accept: application/json" \
-d "client_id=Iv1.b507a08c87ecfe98&device_code=DEVICE_CODE&grant_type=urn:ietf:params:oauth:grant-type:device_code" \
https://github.com/login/oauth/access_token
This returns a ghu_ token that works. But it is short-lived and requires manual renewal.
Additional issue
Default config sets model to copilot/gpt-4 which returns model_not_supported. The API expects bare names like gpt-4o or claude-sonnet-4.6.
Proposed fix
- Implement OAuth device flow directly in the driver
- Auto-refresh the ghu_ token before expiry
- openfang config set-key github-copilot should trigger the device flow
- openfang doctor should check GITHUB_TOKEN when Copilot provider is configured
- Default model names should use bare names not prefixed ones
Environment
- OpenFang v0.5.5
- Linux Debian amd64
- Copilot Enterprise
- Source: crates/openfang-runtime/src/drivers/copilot.rs
Description
The GitHub Copilot LLM driver does not work with any standard GitHub token type. The code says it exchanges a GitHub PAT for a Copilot API token, but the copilot_internal/v2/token endpoint rejects all standard token types:
The only token type that works is a ghu_ token obtained via the OAuth device flow using the VS Code Copilot extension's client ID (Iv1.b507a08c87ecfe98). There is no way for users to generate this through the GitHub website or standard tooling.
Reproduction
Working workaround
Manually run the OAuth device flow:
This returns a ghu_ token that works. But it is short-lived and requires manual renewal.
Additional issue
Default config sets model to copilot/gpt-4 which returns model_not_supported. The API expects bare names like gpt-4o or claude-sonnet-4.6.
Proposed fix
Environment