Description
I'm using createAgentUIStreamResponse. When the user clicks the stop button using stop function from useChat before the AI generates any response, a ZodError is thrown due to an empty message parts array.
plz let me know how to handle stop function
Steps to Reproduce
- Click the chat button to send a message
- Immediately click the stop button before the AI starts responding
- Observe the error
[cause]: Error [ZodError]: [
{
"origin": "array",
"code": "too_small",
"minimum": 1,
"inclusive": true,
"path": [7, "parts"],
"message": "Message must contain at least one part"
}
]
AI SDK Version
- ai: 6.0.3
- @ai-sdk/react: 3.0.3
Code of Conduct