Skip to content

Commit 62ffa8d

Browse files
committed
fix(copilot): align with GitHub Copilot June 2026 rule updates
- Token exchange (`/copilot_internal/v2/token`) now sends `Copilot-Integration-Id` and `X-Github-Api-Version` (openclaw PR #80074, 2026-05-10). - `MakeAuthenticatedRequest` now sends `X-Github-Api-Version` for `/models` and other authenticated calls. - `GetCopilotQuota` now presents the full Copilot client identity headers instead of a `CLIProxyAPIPlus` User-Agent, so `/copilot_internal/user` stays accepted under the new integration-id requirement. - Bump `User-Agent`/`Editor-Version`/`Editor-Plugin-Version` to the community consensus (`GitHubCopilotChat/0.50.0`, `vscode/1.122.0`, `copilot-chat/0.50.0`; caozhiyuan/copilot-api v1.10.22, 2026-05-29). - Sync the header constants across `copilot_auth.go`, `github_copilot_executor.go`, and `api_tools.go` with an explicit keep-in-sync comment.
1 parent 3a4abe1 commit 62ffa8d

3 files changed

Lines changed: 20 additions & 8 deletions

File tree

internal/api/handlers/management/api_tools.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,8 +884,15 @@ func (h *Handler) GetCopilotQuota(c *gin.Context) {
884884
}
885885

886886
req.Header.Set("Authorization", "Bearer "+token)
887-
req.Header.Set("User-Agent", "CLIProxyAPIPlus")
888887
req.Header.Set("Accept", "application/json")
888+
// Present full GitHub Copilot client identity so /copilot_internal/user accepts the
889+
// request after the May 10, 2026 integration-id requirement (openclaw PR #80074).
890+
// Keep values in sync with internal/auth/copilot/copilot_auth.go.
891+
req.Header.Set("User-Agent", "GitHubCopilotChat/0.50.0")
892+
req.Header.Set("Editor-Version", "vscode/1.122.0")
893+
req.Header.Set("Editor-Plugin-Version", "copilot-chat/0.50.0")
894+
req.Header.Set("Copilot-Integration-Id", "vscode-chat")
895+
req.Header.Set("X-Github-Api-Version", "2025-04-01")
889896

890897
httpClient := &http.Client{
891898
Timeout: defaultAPICallTimeout,

internal/auth/copilot/copilot_auth.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ const (
2424
copilotAPIEndpoint = "https://api.githubcopilot.com"
2525

2626
// Common HTTP header values for Copilot API requests.
27-
copilotUserAgent = "GithubCopilot/1.0"
28-
copilotEditorVersion = "vscode/1.100.0"
29-
copilotPluginVersion = "copilot/1.300.0"
27+
// Keep these in sync with internal/runtime/executor/github_copilot_executor.go.
28+
copilotUserAgent = "GitHubCopilotChat/0.50.0"
29+
copilotEditorVersion = "vscode/1.122.0"
30+
copilotPluginVersion = "copilot-chat/0.50.0"
3031
copilotIntegrationID = "vscode-chat"
31-
copilotOpenAIIntent = "conversation-panel"
32+
copilotOpenAIIntent = "conversation-edits"
33+
copilotGitHubAPIVer = "2025-04-01"
3234
)
3335

3436
// CopilotAPIToken represents the Copilot API token response.
@@ -119,6 +121,8 @@ func (c *CopilotAuth) GetCopilotAPIToken(ctx context.Context, githubAccessToken
119121
req.Header.Set("User-Agent", copilotUserAgent)
120122
req.Header.Set("Editor-Version", copilotEditorVersion)
121123
req.Header.Set("Editor-Plugin-Version", copilotPluginVersion)
124+
req.Header.Set("Copilot-Integration-Id", copilotIntegrationID)
125+
req.Header.Set("X-Github-Api-Version", copilotGitHubAPIVer)
122126

123127
resp, err := c.httpClient.Do(req)
124128
if err != nil {
@@ -220,6 +224,7 @@ func (c *CopilotAuth) MakeAuthenticatedRequest(ctx context.Context, method, url
220224
req.Header.Set("Editor-Plugin-Version", copilotPluginVersion)
221225
req.Header.Set("Openai-Intent", copilotOpenAIIntent)
222226
req.Header.Set("Copilot-Integration-Id", copilotIntegrationID)
227+
req.Header.Set("X-Github-Api-Version", copilotGitHubAPIVer)
223228

224229
return req, nil
225230
}

internal/runtime/executor/github_copilot_executor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ const (
3838
maxScannerBufferSize = 20_971_520
3939

4040
// Copilot API header values.
41-
copilotUserAgent = "GitHubCopilotChat/0.35.0"
42-
copilotEditorVersion = "vscode/1.107.0"
43-
copilotPluginVersion = "copilot-chat/0.35.0"
41+
copilotUserAgent = "GitHubCopilotChat/0.50.0"
42+
copilotEditorVersion = "vscode/1.122.0"
43+
copilotPluginVersion = "copilot-chat/0.50.0"
4444
copilotIntegrationID = "vscode-chat"
4545
copilotOpenAIIntent = "conversation-edits"
4646
copilotGitHubAPIVer = "2025-04-01"

0 commit comments

Comments
 (0)