Skip to content

Commit 561afb4

Browse files
authored
fix(opencode): detect Copilot PDF input support (anomalyco#41522)
1 parent 2b8a596 commit 561afb4

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

‎packages/opencode/src/plugin/github-copilot/models.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ function build(key: string, remote: SelectableItem, url: string, prev?: Model):
8888
const image =
8989
(remote.capabilities.supports.vision ?? false) ||
9090
(remote.capabilities.limits.vision?.supported_media_types ?? []).some((item) => item.startsWith("image/"))
91+
const pdf =
92+
(remote.capabilities.supports.vision ?? false) &&
93+
(remote.capabilities.limits.vision?.supported_media_types?.includes("application/pdf") ?? false)
9194

9295
const isMsgApi = remote.supported_endpoints?.includes("/v1/messages")
9396
const endpoint: CopilotEndpoint | undefined = isMsgApi
@@ -127,7 +130,7 @@ function build(key: string, remote: SelectableItem, url: string, prev?: Model):
127130
audio: false,
128131
image,
129132
video: false,
130-
pdf: false,
133+
pdf,
131134
},
132135
output: {
133136
text: true,

‎packages/opencode/test/plugin/github-copilot-models.test.ts‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,74 @@ test("converts Copilot AIC token prices to USD per million tokens", async () =>
187187
expect(models["ignored-non-chat-record"]).toBeUndefined()
188188
})
189189

190+
test("detects PDF input support when vision and media type are advertised", async () => {
191+
globalThis.fetch = mock(() =>
192+
Promise.resolve(
193+
new Response(
194+
JSON.stringify({
195+
data: [
196+
{
197+
model_picker_enabled: true,
198+
id: "pdf-model",
199+
name: "PDF Model",
200+
version: "pdf-model-2026-06-01",
201+
capabilities: {
202+
family: "pdf-model",
203+
limits: {
204+
max_context_window_tokens: 128000,
205+
max_output_tokens: 16384,
206+
max_prompt_tokens: 128000,
207+
vision: {
208+
max_prompt_image_size: 10000000,
209+
max_prompt_images: 10,
210+
supported_media_types: ["application/pdf"],
211+
},
212+
},
213+
supports: {
214+
streaming: true,
215+
vision: true,
216+
tool_calls: true,
217+
},
218+
},
219+
},
220+
{
221+
model_picker_enabled: true,
222+
id: "vision-only-model",
223+
name: "Vision Only Model",
224+
version: "vision-only-model-2026-06-01",
225+
capabilities: {
226+
family: "vision-only-model",
227+
limits: {
228+
max_context_window_tokens: 128000,
229+
max_output_tokens: 16384,
230+
max_prompt_tokens: 128000,
231+
vision: {
232+
max_prompt_image_size: 10000000,
233+
max_prompt_images: 10,
234+
supported_media_types: ["image/png"],
235+
},
236+
},
237+
supports: {
238+
streaming: true,
239+
vision: true,
240+
tool_calls: true,
241+
},
242+
},
243+
},
244+
],
245+
}),
246+
{ status: 200 },
247+
),
248+
),
249+
) as unknown as typeof fetch
250+
251+
const models = (await CopilotModels.get("https://api.githubcopilot.com")).models
252+
const model = models["pdf-model"]
253+
254+
expect(model.capabilities.input.pdf).toBe(true)
255+
expect(models["vision-only-model"].capabilities.input.pdf).toBe(false)
256+
})
257+
190258
test("uses zero cost when Copilot reports a zero billing batch size", async () => {
191259
globalThis.fetch = mock(() =>
192260
Promise.resolve(

0 commit comments

Comments
 (0)