Open History to see the last commit
1import { test, expect } from './fixtures'
2
3/**
4 * OpenRouter Responses through the real SDK parser:
5 * - a function call item that the SDK cannot parse still runs its tool,
6 * - cached input tokens reach the usage,
7 * - the function call namespace goes back on the replay request.
8 */
9test('openrouter-responses keeps stream fields through the SDK parser', async ({
10 request,
11}) => {
12 const response = await request.post('/api/openrouter-responses-stream-fields')
13 expect(response.ok()).toBe(true)
14 const result = await response.json()
15 expect(result.toolNames).toEqual(
16 expect.arrayContaining(['search_docs', 'lookup']),
17 )
18 expect(result.usage).toMatchObject({
19 promptTokens: 100,
20 promptTokensDetails: { cachedTokens: 40 },
21 })
22 expect(result.replayCalls).toContainEqual(
23 expect.objectContaining({ name: 'search_docs', namespace: 'docs' }),
24 )
25})