Open History to see the last commit
1import { test, expect } from './fixtures'
2import {
3 selectScenario,
4 runTest,
5 waitForTestComplete,
6 getMetadata,
7 getToolCalls,
8} from './tools-test/helpers'
9
10test.describe('Tool Error Handling', () => {
11 test('tool that throws error produces error result and chat continues', async ({
12 page,
13 testId,
14 aimockPort,
15 }) => {
16 await selectScenario(page, 'tool-error', testId, aimockPort)
17 await runTest(page)
18
19 // The agentic loop should handle the tool error and continue
20 // (the tool throws, error becomes the tool result, LLM responds to the error)
21 await waitForTestComplete(page, 15000, 1)
22
23 const metadata = await getMetadata(page)
24 // Tool was called even though it threw
25 expect(parseInt(metadata.toolCallCount)).toBeGreaterThanOrEqual(1)
26
27 const toolCalls = await getToolCalls(page)
28 const failingCall = toolCalls.find(
29 (tc: { name: string }) => tc.name === 'failing_tool',
30 )
31 expect(failingCall).toBeDefined()
32 // The failed tool-call part reaches the terminal 'error' state, so UIs can
33 // distinguish "failed" from "still executing" without reverse-engineering
34 // the output shape (issue #718).
35 expect(failingCall?.state).toBe('error')
36 })
37})