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

server-tool-store-wire.spec.ts

26 lines983 Bytes

1import { test, expect } from './fixtures'
2​
3/**
4 * Claude thinks, calls a server tool with no text first, then answers in a
5 * second call. With `withPersistence`, the next turn must send that tool call
6 * to Claude once. `/api/server-tool-store-wire` runs both turns and returns
7 * what Claude received and what the store kept.
8 */
9test.describe('server tool before text — message ids across calls', () => {
10 test('the next turn and the store hold the tool call once', async ({
11 request,
12 }) => {
13 const response = await request.post('/api/server-tool-store-wire')
14 expect(response.ok()).toBe(true)
15 const result = (await response.json()) as {
16 ok: boolean
17 error?: string
18 turn2ToolUseIds: Array<string>
19 storedToolCallIds: Array<string>
20 }
21 if (!result.ok) throw new Error(`Route failed: ${result.error}`)
22​
23 expect(result.turn2ToolUseIds).toEqual(['toolu_lookup'])
24 expect(result.storedToolCallIds).toEqual(['toolu_lookup'])
25 })
26})