Skip to content

Commit e365766

Browse files
committed
test(e2e): consume open START on END in pairing invariant
A second TOOL_CALL_END for the same toolCallId now fails the pairing check directly, matching how @ag-ui/client's verifyEvents closes open tool calls. Addresses CodeRabbit review feedback on #696.
1 parent 4d1586c commit e365766

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

testing/e2e/tests/tool-call-lifecycle.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ test.describe('chat() tool-call lifecycle (#519)', () => {
4141
// The server tool actually ran — its result reached the stream.
4242
expect(results[0]).toMatchObject({ content: expect.stringContaining('22') })
4343

44-
// verifyEvents invariant: every END is preceded by a matching START.
44+
// verifyEvents invariant: every END consumes a matching open START, so a
45+
// duplicate END for the same toolCallId finds none and fails here.
4546
const open = new Set<string>()
4647
for (const c of chunks) {
4748
if (c.type === 'TOOL_CALL_START') open.add(idOf(c))
4849
if (c.type === 'TOOL_CALL_END') {
49-
expect(open.has(idOf(c))).toBe(true)
50+
const id = idOf(c)
51+
expect(open.has(id)).toBe(true)
52+
open.delete(id)
5053
}
5154
}
5255
})

0 commit comments

Comments
 (0)