| 323 | // Streaming callback that logs chunks - Logger dispatches events automatically |
| 324 | let isFirstChunk = true; |
| 325 | const onStreamChunk = (chunk: string) => { |
| 326 | try { |
| 327 | if (isFirstChunk) { |
| 328 | Logger.debug(agentId, 'Stream started', { logType: 'stream-start', iterationId }); |
| 329 | isFirstChunk = false; |
| 330 | } |
| 331 | Logger.debug(agentId, 'Stream chunk', { logType: 'stream-chunk', iterationId, content: { chunk } }); |
| 332 | } catch (error) { |
| 333 | Logger.debug(agentId, `Failed to log streaming event: ${error}`, { iterationId }); |
| 334 | } |
| 335 | }; |
| 336 | |
| 337 | const onReasoningChunk = (chunk: string) => { |
| 338 | try { |