Open History to see the last commit
1import { test, expect } from './fixtures'
2
3interface WireMessage {
4 role: string
5 text: string
6}
7
8test.describe('harness: continue after a partial answer', () => {
9 test('a stream that fails in the middle continues its partial text', async ({
10 request,
11 }) => {
12 const res = await request.post('/api/harness-continue')
13 expect(res.ok()).toBe(true)
14 const result: {
15 error?: string
16 text: string
17 deltas: Array<string>
18 requests: Array<Array<WireMessage>>
19 } = await res.json()
20 expect(result.error ?? null).toBeNull()
21
22 expect(result.text).toBe('Hello world')
23 // session.onEvent saw the streamed text of both model calls.
24 expect(result.deltas.join('')).toBe('Hello world')
25 expect(result.requests).toHaveLength(2)
26 const [prompt, partial, note] = result.requests[1]!
27 expect(prompt).toEqual({
28 role: 'user',
29 text: '[harness-continue] say hello world',
30 })
31 expect(partial).toEqual({ role: 'assistant', text: 'Hello wor' })
32 expect(note!.role).toBe('user')
33 expect(note!.text).toContain('Continue from the exact point')
34 })
35})