From 21fbf21cb666856c5b29c94617db759737825f24 Mon Sep 17 00:00:00 2001 From: Timo Clasen Date: Tue, 8 Jul 2025 21:01:54 +0200 Subject: [PATCH] fix(copilot): add vision request header (#773) --- packages/opencode/src/provider/provider.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/opencode/src/provider/provider.ts b/packages/opencode/src/provider/provider.ts index 730d920b..920db882 100644 --- a/packages/opencode/src/provider/provider.ts +++ b/packages/opencode/src/provider/provider.ts @@ -99,19 +99,27 @@ export namespace Provider { info.access = tokens.access } let isAgentCall = false + let isVisionRequest = false try { const body = typeof init.body === "string" ? JSON.parse(init.body) : init.body if (body?.messages) { isAgentCall = body.messages.some((msg: any) => msg.role && ["tool", "assistant"].includes(msg.role)) + isVisionRequest = body.messages.some( + (msg: any) => + Array.isArray(msg.content) && msg.content.some((part: any) => part.type === "image_url"), + ) } } catch {} - const headers = { + const headers: Record = { ...init.headers, ...copilot.HEADERS, Authorization: `Bearer ${info.access}`, "Openai-Intent": "conversation-edits", "X-Initiator": isAgentCall ? "agent" : "user", } + if (isVisionRequest) { + headers["Copilot-Vision-Request"] = "true" + } delete headers["x-api-key"] return fetch(input, { ...init,