Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

structured-output-length-wire.spec.ts

28 lines979 Bytes

1import { test, expect } from './fixtures'
2​
3/**
4 * Issue #1426: a structured-output response cut off at the output cap used to
5 * fail with a JSON parse error (or "no content"), which reads like a schema
6 * problem. It must say the token limit was reached.
7 */
8test.describe('structured output — finish_reason=length', () => {
9 test('reports truncation instead of a parse error', async ({ request }) => {
10 const response = await request.post('/api/structured-output-length-wire')
11 expect(response.ok()).toBe(true)
12 const { errors } = (await response.json()) as {
13 errors: Record<string, string | null>
14 }
15​
16 expect(Object.keys(errors).sort()).toEqual([
17 'compatible-empty',
18 'compatible-truncated',
19 'openrouter-empty',
20 'openrouter-truncated',
21 ])
22 for (const [label, message] of Object.entries(errors)) {
23 expect(message, label).toContain(
24 'cut off because the maximum token limit was reached',
25 )
26 }
27 })
28})