Open History to see the last commit
1import { test, expect } from './fixtures'
2import {
3 sendMessage,
4 waitForResponse,
5 getToolCalls,
6 waitForAssistantText,
7 featureUrl,
8} from './helpers'
9import { providersFor } from './test-matrix'
10
11for (const provider of providersFor('tool-calling')) {
12 test.describe(`${provider} — tool-calling`, () => {
13 test('calls getGuitars and displays result', async ({
14 page,
15 testId,
16 aimockPort,
17 }) => {
18 await page.goto(featureUrl(provider, 'tool-calling', testId, aimockPort))
19
20 await sendMessage(page, '[toolcall] what guitars do you have in stock')
21 await waitForResponse(page)
22
23 const toolCalls = await getToolCalls(page)
24 expect(toolCalls.length).toBeGreaterThanOrEqual(1)
25 expect(toolCalls[0].name).toBe('getGuitars')
26
27 // The parsed `input` is populated on the tool-call part (previously it
28 // was always `undefined` at runtime — only `arguments` was set). It is
29 // the raw `arguments` string parsed as JSON. `getGuitars` takes no
30 // arguments, so it serializes as `{}` — assert the round-trip whenever
31 // the args carry a JSON value (an empty/absent args string correctly
32 // parses to no input, so we don't force a non-empty input there).
33 const inputText = await page
34 .getByTestId('tool-call-input-getGuitars')
35 .locator('code')
36 .first()
37 .innerText()
38 const argsText = (
39 await page
40 .getByTestId('tool-call-getGuitars')
41 .locator('code')
42 .first()
43 .innerText()
44 ).trim()
45 if (argsText.length > 0) {
46 expect(JSON.parse(inputText)).toEqual(JSON.parse(argsText))
47 }
48
49 // Wait for the text response after tool execution (agentic loop's second LLM call)
50 await waitForAssistantText(page, 'Fender Stratocaster')
51 })
52 })
53}