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

ag-ui-foreign-client.spec.ts

65 lines1.7 KB

1import { test, expect } from './fixtures'
2​
3test.describe('AG-UI foreign client compatibility', () => {
4 test('TanStack server accepts pure RunAgentInput with fan-out tool messages', async ({
5 request,
6 testId,
7 aimockPort,
8 }) => {
9 const body = {
10 threadId: 'thread-foreign-1',
11 runId: 'run-foreign-1',
12 state: {},
13 messages: [
14 { id: 'u1', role: 'user', content: '[chat] recommend a guitar' },
15 ],
16 tools: [],
17 context: [],
18 forwardedProps: {
19 provider: 'openai',
20 feature: 'chat',
21 testId,
22 aimockPort,
23 },
24 }
25 const response = await request.post('/api/chat', {
26 data: body,
27 headers: { 'Content-Type': 'application/json' },
28 })
29 expect(
30 response.ok(),
31 `expected 200, got ${response.status()}: ${await response.text()}`,
32 ).toBe(true)
33 const text = await response.text()
34 expect(text).toContain('RUN_FINISHED')
35 })
36​
37 test('developer role is collapsed to system without breaking the run', async ({
38 request,
39 testId,
40 aimockPort,
41 }) => {
42 const body = {
43 threadId: 'thread-foreign-2',
44 runId: 'run-foreign-2',
45 state: {},
46 messages: [
47 { id: 'd1', role: 'developer', content: 'You only speak in haiku.' },
48 { id: 'u1', role: 'user', content: '[chat] recommend a guitar' },
49 ],
50 tools: [],
51 context: [],
52 forwardedProps: {
53 provider: 'openai',
54 feature: 'chat',
55 testId,
56 aimockPort,
57 },
58 }
59 const response = await request.post('/api/chat', {
60 data: body,
61 headers: { 'Content-Type': 'application/json' },
62 })
63 expect(response.ok()).toBe(true)
64 })
65})