Open History to see the last commit
1import { expect, test } from '../fixtures'
2import {
3 getMessages,
4 runTest,
5 selectScenario,
6 waitForTestComplete,
7} from './helpers'
8
9/**
10 * Regression tests for issue #1017.
11 *
12 * The `interleaved-args` scenario streams a TEXT_MESSAGE_CONTENT delta
13 * between two TOOL_CALL_ARGS deltas (`{"city":"New Yo` + `rk City"}`).
14 * Pre-fix, the interleaved text force-completed the tool call and
15 * populated `input` from a lenient partial-JSON parse of the truncated
16 * arguments (`{"city":"New Yo"}`).
17 */
18test.describe('Interleaved Text/Args (tools-test page)', () => {
19 test('tool-call input matches the full arguments despite interleaved text', async ({
20 page,
21 testId,
22 aimockPort,
23 }) => {
24 await selectScenario(page, 'interleaved-args', testId, aimockPort)
25 await runTest(page)
26 await waitForTestComplete(page)
27
28 const messages = await getMessages(page)
29 const toolCallParts = messages
30 .flatMap((msg) => msg.parts || [])
31 .filter((part) => part.type === 'tool-call')
32
33 expect(toolCallParts).toHaveLength(1)
34 const part = toolCallParts[0]
35 expect(part.name).toBe('get_weather')
36 expect(part.state).toBe('complete')
37 expect(part.arguments).toBe('{"city":"New York City"}')
38 expect(part.input).toEqual({ city: 'New York City' })
39 })
40})