mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-30 00:42:25 +00:00
fix(core): preserve Responses tool strictness (#45663)
This commit is contained in:
parent
64ef85159d
commit
0123fed65d
3 changed files with 26 additions and 1 deletions
5
.changeset/responses-tool-strictness.md
Normal file
5
.changeset/responses-tool-strictness.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@opencode-ai/core": patch
|
||||
---
|
||||
|
||||
Preserve explicit function tool strictness in Copilot Responses requests.
|
||||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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 })
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue