fix(core): preserve Responses tool strictness (#45663)

This commit is contained in:
Kit Langton 2026-08-27 23:01:43 -04:00 committed by GitHub
parent 64ef85159d
commit 0123fed65d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"@opencode-ai/core": patch
---
Preserve explicit function tool strictness in Copilot Responses requests.

View file

@ -47,7 +47,7 @@ export function prepareResponsesTools({
name: tool.name,
description: tool.description,
parameters: tool.inputSchema,
strict: strictJsonSchema,
strict: tool.strict ?? strictJsonSchema,
})
break
case "provider": {

View file

@ -0,0 +1,20 @@
import { expect, test } from "bun:test"
import type { LanguageModelV3FunctionTool } from "@ai-sdk/provider"
import { prepareResponsesTools } from "@opencode-ai/core/github-copilot/responses/openai-responses-prepare-tools"
function prepare(strict: boolean | undefined, strictJsonSchema: boolean) {
const tool: LanguageModelV3FunctionTool = {
type: "function",
name: "lookup",
inputSchema: { type: "object", properties: {} },
strict,
}
return prepareResponsesTools({ tools: [tool], strictJsonSchema }).tools?.[0]
}
test("function tools prefer explicit strictness over the global fallback", () => {
expect(prepare(true, false)).toMatchObject({ type: "function", strict: true })
expect(prepare(false, true)).toMatchObject({ type: "function", strict: false })
expect(prepare(undefined, true)).toMatchObject({ type: "function", strict: true })
expect(prepare(undefined, false)).toMatchObject({ type: "function", strict: false })
})