mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
ElevenLabs only passed bootstrap context through dynamicVariables without
a matching {{initialConversationContext}} prompt placeholder, so Brief me
connected with no session history. Stream deferred chunks then push bootstrap
on all backends; add the placeholder for newly created ConvAI agents.
Co-authored-by: Cursor <cursoragent@cursor.com>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { describe, expect, test, vi } from 'vitest'
|
|
import { deliverVoiceSessionContextAfterConnect } from './voiceContextStream'
|
|
|
|
describe('deliverVoiceSessionContextAfterConnect', () => {
|
|
test('streams older chunks then bootstrap context', async () => {
|
|
const sent: string[] = []
|
|
const sendChunk = vi.fn((chunk: string) => {
|
|
sent.push(chunk)
|
|
})
|
|
|
|
await deliverVoiceSessionContextAfterConnect({
|
|
streamContextChunks: ['older-a', 'older-b'],
|
|
initialContext: 'bootstrap recent',
|
|
sendChunk
|
|
})
|
|
|
|
expect(sent).toEqual(['older-a', 'older-b', 'bootstrap recent'])
|
|
})
|
|
|
|
test('sends bootstrap even when there are no stream chunks', async () => {
|
|
const sent: string[] = []
|
|
|
|
await deliverVoiceSessionContextAfterConnect({
|
|
initialContext: ' session header only ',
|
|
sendChunk: (chunk) => sent.push(chunk)
|
|
})
|
|
|
|
expect(sent).toEqual(['session header only'])
|
|
})
|
|
|
|
test('skips empty bootstrap', async () => {
|
|
const sent: string[] = []
|
|
|
|
await deliverVoiceSessionContextAfterConnect({
|
|
streamContextChunks: ['chunk'],
|
|
initialContext: ' ',
|
|
sendChunk: (chunk) => sent.push(chunk)
|
|
})
|
|
|
|
expect(sent).toEqual(['chunk'])
|
|
})
|
|
})
|