The program crashes when the stop reason is a safety issue. Also, when using streamUI there doesn't seem to be a way to handle the finishedReason nor usage.
Using streamUI, setup a chatbot. Then ask it to "tell me a joke about a clown" or something like that. It triggers the safety issue, but I cannot seem to catch and handle it. The getToolCallsFromParts is the call causing the crash issue.
Description
The program crashes when the stop reason is a safety issue. Also, when using streamUI there doesn't seem to be a way to handle the finishedReason nor usage.
Using streamUI, setup a chatbot. Then ask it to "tell me a joke about a clown" or something like that. It triggers the safety issue, but I cannot seem to catch and handle it. The
getToolCallsFromParts
is the call causing the crash issue.Code example
No response
Additional context
Unhandled Runtime Error Error: Cannot read properties of undefined (reading 'flatMap')
Call Stack getToolCallsFromParts (rsc)\node_modules.pnpm\@ai-sdk+google-vertex@0.0.5_zod@3.23.8\node_modules\@ai-sdk\google-vertex\dist\index.mjs (487:0) Object.transform (rsc)\node_modules.pnpm\@ai-sdk+google-vertex@0.0.5_zod@3.23.8\node_modules\@ai-sdk\google-vertex\dist\index.mjs (413:0) invokePromiseCallback node:internal/webstreams/util (180:10) Object.
node:internal/webstreams/util (185:23)
transformStreamDefaultControllerPerformTransform
node:internal/webstreams/transformstream (517:37)
transformStreamDefaultSinkWriteAlgorithm
node:internal/webstreams/transformstream (563:10)