A native-combined turn: the schema-constrained JSON arrives as assistant text.
(json: string)
| 41 | |
| 42 | /** A native-combined turn: the schema-constrained JSON arrives as assistant text. */ |
| 43 | function textTurn(json: string): Array<StreamChunk> { |
| 44 | const timestamp = Date.now() |
| 45 | return [ |
| 46 | { type: EventType.RUN_STARTED, runId: 'r1', threadId: 't1', timestamp }, |
| 47 | { |
| 48 | type: EventType.TEXT_MESSAGE_START, |
| 49 | messageId: 'm1', |
| 50 | role: 'assistant', |
| 51 | timestamp, |
| 52 | }, |
| 53 | { |
| 54 | type: EventType.TEXT_MESSAGE_CONTENT, |
| 55 | messageId: 'm1', |
| 56 | delta: json, |
| 57 | timestamp, |
| 58 | }, |
| 59 | { type: EventType.TEXT_MESSAGE_END, messageId: 'm1', timestamp }, |
| 60 | { |
| 61 | type: EventType.RUN_FINISHED, |
| 62 | runId: 'r1', |
| 63 | threadId: 't1', |
| 64 | finishReason: 'stop', |
| 65 | timestamp, |
| 66 | }, |
| 67 | ] as Array<StreamChunk> |
| 68 | } |
| 69 | |
| 70 | describe('structured output null normalization', () => { |
| 71 | it('drops a provider null for an optional field so validation passes', async () => { |