Skip to content

Commit 0123fed

Browse files
authored
fix(core): preserve Responses tool strictness (anomalyco#45663)
1 parent 64ef851 commit 0123fed

3 files changed

Lines changed: 26 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opencode-ai/core": patch
3+
---
4+
5+
Preserve explicit function tool strictness in Copilot Responses requests.

‎packages/core/src/github-copilot/responses/openai-responses-prepare-tools.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function prepareResponsesTools({
4747
name: tool.name,
4848
description: tool.description,
4949
parameters: tool.inputSchema,
50-
strict: strictJsonSchema,
50+
strict: tool.strict ?? strictJsonSchema,
5151
})
5252
break
5353
case "provider": {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { expect, test } from "bun:test"
2+
import type { LanguageModelV3FunctionTool } from "@ai-sdk/provider"
3+
import { prepareResponsesTools } from "@opencode-ai/core/github-copilot/responses/openai-responses-prepare-tools"
4+
5+
function prepare(strict: boolean | undefined, strictJsonSchema: boolean) {
6+
const tool: LanguageModelV3FunctionTool = {
7+
type: "function",
8+
name: "lookup",
9+
inputSchema: { type: "object", properties: {} },
10+
strict,
11+
}
12+
return prepareResponsesTools({ tools: [tool], strictJsonSchema }).tools?.[0]
13+
}
14+
15+
test("function tools prefer explicit strictness over the global fallback", () => {
16+
expect(prepare(true, false)).toMatchObject({ type: "function", strict: true })
17+
expect(prepare(false, true)).toMatchObject({ type: "function", strict: false })
18+
expect(prepare(undefined, true)).toMatchObject({ type: "function", strict: true })
19+
expect(prepare(undefined, false)).toMatchObject({ type: "function", strict: false })
20+
})

0 commit comments

Comments
 (0)