Open History to see the last commit
1import { test, expect } from './fixtures'
2
3type JournalEntry = {
4 headers?: Record<string, string>
5 body: {
6 reasoning?: Record<string, unknown>
7 } | null
8}
9
10test.describe('openrouter — reasoning wire format', () => {
11 for (const scenario of ['disabled', 'empty'] as const) {
12 test(`${scenario} reasoning is normalized on the wire (#1006)`, async ({
13 request,
14 aimockPort,
15 testId,
16 }) => {
17 const response = await request.post(
18 `/api/openrouter-reasoning-wire?testId=${encodeURIComponent(testId)}&scenario=${scenario}`,
19 )
20 expect(response.ok()).toBe(true)
21 expect(((await response.json()) as { ok: boolean }).ok).toBe(true)
22
23 const journalResponse = await request.get(
24 `http://127.0.0.1:${aimockPort}/v1/_requests`,
25 )
26 const entries = (await journalResponse.json()) as Array<JournalEntry>
27 const captured = entries.find(
28 (entry) => entry.headers?.['x-test-id'] === testId,
29 )
30 expect(captured).toBeDefined()
31 expect(captured?.body).toEqual(expect.any(Object))
32
33 if (scenario === 'disabled') {
34 expect(captured?.body?.reasoning).toEqual({ effort: 'none' })
35 } else {
36 expect(captured?.body).not.toHaveProperty('reasoning')
37 }
38 })
39 }
40})