From 36c3d15b3f0ea40af5f058cc4face7ba2a7210f7 Mon Sep 17 00:00:00 2001 From: Aiden Cline Date: Sun, 31 May 2026 23:34:17 -0500 Subject: [PATCH] fix(opencode): add Copilot request headers --- packages/opencode/src/plugin/github-copilot/copilot.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/opencode/src/plugin/github-copilot/copilot.ts b/packages/opencode/src/plugin/github-copilot/copilot.ts index d24d9b9dae..deafc9031d 100644 --- a/packages/opencode/src/plugin/github-copilot/copilot.ts +++ b/packages/opencode/src/plugin/github-copilot/copilot.ts @@ -10,6 +10,8 @@ import { MessageV2 } from "@/session/message-v2" const log = Log.create({ service: "plugin.copilot" }) const CLIENT_ID = "Ov23li8tweQw6odWQebz" +const API_VERSION = "2026-06-01" +const UTILITY_MODELS = new Set(["gpt-4o-mini", "gpt-4.1", "gpt-4o", "gpt-5.4-nano"]) // Add a small safety buffer when polling to avoid hitting the server // slightly too early due to clock skew / timer drift. const OAUTH_POLLING_SAFETY_MARGIN_MS = 3000 // 3 seconds @@ -71,6 +73,7 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise { { Authorization: `Bearer ${auth.refresh}`, "User-Agent": `opencode/${InstallationVersion}`, + "X-GitHub-Api-Version": API_VERSION, }, provider.models, ).catch((error) => { @@ -345,6 +348,11 @@ export async function CopilotAuthPlugin(input: PluginInput): Promise { "chat.headers": async (incoming, output) => { if (!incoming.model.providerID.includes("github-copilot")) return + output.headers["X-GitHub-Api-Version"] = API_VERSION + if (incoming.agent === "title" && UTILITY_MODELS.has(incoming.model.api.id)) { + output.headers["X-Interaction-Type"] = "agent-session-name-generation" + } + if (incoming.model.api.npm === "@ai-sdk/anthropic") { output.headers["anthropic-beta"] = "interleaved-thinking-2025-05-14" }