@@ -2318,7 +2318,7 @@ describe("openai transport stream", () => {
|
2318 | 2318 | expect(functionCall?.arguments).toBe("not valid json"); |
2319 | 2319 | }); |
2320 | 2320 | |
2321 | | -it("does not send tool_choice when tools are provided but toolChoice option is not set", () => { |
| 2321 | +it("defaults tool_choice to auto for proxy-like openai-completions endpoints", () => { |
2322 | 2322 | const params = buildOpenAICompletionsParams( |
2323 | 2323 | { |
2324 | 2324 | id: "test-model", |
@@ -2346,6 +2346,38 @@ describe("openai transport stream", () => {
|
2346 | 2346 | undefined, |
2347 | 2347 | ); |
2348 | 2348 | |
| 2349 | +expect(params).toHaveProperty("tools"); |
| 2350 | +expect(params).toHaveProperty("tool_choice", "auto"); |
| 2351 | +}); |
| 2352 | + |
| 2353 | +it("does not send tool_choice by default for native openai-completions endpoints", () => { |
| 2354 | +const params = buildOpenAICompletionsParams( |
| 2355 | +{ |
| 2356 | +id: "gpt-5.4", |
| 2357 | +name: "GPT-5.4", |
| 2358 | +api: "openai-completions", |
| 2359 | +provider: "openai", |
| 2360 | +baseUrl: "https://api.openai.com/v1", |
| 2361 | +reasoning: false, |
| 2362 | +input: ["text"], |
| 2363 | +cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }, |
| 2364 | +contextWindow: 4096, |
| 2365 | +maxTokens: 2048, |
| 2366 | +} satisfies Model<"openai-completions">, |
| 2367 | +{ |
| 2368 | +systemPrompt: "You are a helpful assistant", |
| 2369 | +messages: [], |
| 2370 | +tools: [ |
| 2371 | +{ |
| 2372 | +name: "get_weather", |
| 2373 | +description: "Get weather information", |
| 2374 | +parameters: { type: "object", properties: {} }, |
| 2375 | +}, |
| 2376 | +], |
| 2377 | +} as never, |
| 2378 | +undefined, |
| 2379 | +); |
| 2380 | + |
2349 | 2381 | expect(params).toHaveProperty("tools"); |
2350 | 2382 | expect(params).not.toHaveProperty("tool_choice"); |
2351 | 2383 | }); |
|