Skip to content

Commit 33d7dd7

Browse files
committed
test: add strict tool-calling tests for responses
1 parent d1a6884 commit 33d7dd7

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { describe, it, expect } from "vitest";
2+
import { ChatOpenAIResponses } from "../responses";
3+
4+
describe("strict tool-calling configuration", () => {
5+
it("falls back to supportsStrictToolCalling when strict is undefined", () => {
6+
const model = new ChatOpenAIResponses({
7+
model: "gpt-4o",
8+
supportsStrictToolCalling: true,
9+
});
10+
11+
const params = model.invocationParams({
12+
tools: [
13+
{
14+
type: "function",
15+
function: {
16+
name: "test_func",
17+
description: "testing",
18+
parameters: { type: "object", properties: {} },
19+
},
20+
},
21+
],
22+
});
23+
24+
expect((params as any).strict).toBeUndefined();
25+
26+
expect((params.tools as any)[0].strict).toBe(true);
27+
});
28+
29+
it("respects user-provided strict option", () => {
30+
const model = new ChatOpenAIResponses({
31+
model: "gpt-4o",
32+
supportsStrictToolCalling: true,
33+
});
34+
35+
const params = model.invocationParams({
36+
strict: false,
37+
tools: [
38+
{
39+
type: "function",
40+
function: {
41+
name: "test_func",
42+
description: "testing",
43+
parameters: { type: "object", properties: {} },
44+
},
45+
},
46+
],
47+
});
48+
49+
expect((params as any).strict).toBeUndefined();
50+
51+
expect((params.tools as any)[0].strict).toBe(false);
52+
});
53+
});

0 commit comments

Comments
 (0)