Open History to see the last commit
1import { expect, test } from './fixtures'
2
3test.describe('mistral strict tool optional fields', () => {
4 test('undoes provider-added nullability before tool validation and execution', async ({
5 request,
6 }) => {
7 const response = await request.post('/api/mistral-strict-tool-null-wire')
8 expect(response.ok()).toBe(true)
9 const result = (await response.json()) as {
10 ok: boolean
11 error?: string
12 requestCount: number
13 firstRequestBody: {
14 tools: Array<{
15 function: {
16 name: string
17 strict: boolean
18 parameters: {
19 required: Array<string>
20 properties: Record<
21 string,
22 {
23 type?: string | Array<string>
24 anyOf?: Array<{ type: string }>
25 enum?: Array<unknown>
26 }
27 >
28 }
29 }
30 }>
31 }
32 executedInput: Record<string, unknown>
33 text: string
34 }
35
36 if (!result.ok) throw new Error(`Route failed: ${result.error}`)
37
38 const tool = result.firstRequestBody.tools.find(
39 (entry) => entry.function.name === 'ask_user',
40 )
41 expect(tool).toMatchObject({
42 function: {
43 name: 'ask_user',
44 strict: true,
45 parameters: {
46 required: ['mode', 'question', 'options', 'nullableNote'],
47 properties: {
48 mode: {
49 type: ['string', 'null'],
50 enum: ['canary', null],
51 },
52 options: { type: ['array', 'null'] },
53 nullableNote: {
54 anyOf: [{ type: 'string' }, { type: 'null' }],
55 },
56 },
57 },
58 },
59 })
60 expect(result.executedInput).toEqual({
61 question: 'Which option?',
62 nullableNote: null,
63 })
64 expect(result.requestCount).toBe(2)
65 expect(result.text).toBe('Tool executed.')
66 })
67})