I unfortunately don’t have a reproducer I can easily extract, but the API was sending a response with {”type”: “finish”, “finishReason”: "stop”} and this was crashing the frontend (still using version 5.0.86)
436.3fe587091bcb2bda.js:3 AI_TypeValidationError: Type validation failed: Value: {“type”:“finish”,“finishReason”:“stop”}.
Error message: [
{“code”: “invalid_union”,“errors”: [[{“code”: “invalid_value”,“values”: [“text-start”],“path”: [“type”],“message”: “Invalid input: expected “text-start””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“id”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“text-delta”],“path”: [“type”],“message”: “Invalid input: expected “text-delta””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“id”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“delta”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“text-end”],“path”: [“type”],“message”: “Invalid input: expected “text-end””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“id”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“error”],“path”: [“type”],“message”: “Invalid input: expected “error””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“errorText”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“tool-input-start”],“path”: [“type”],“message”: “Invalid input: expected “tool-input-start””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolCallId”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolName”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“tool-input-delta”],“path”: [“type”],“message”: “Invalid input: expected “tool-input-delta””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolCallId”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“inputTextDelta”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“tool-input-available”],“path”: [“type”],“message”: “Invalid input: expected “tool-input-available””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolCallId”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolName”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“tool-input-error”],“path”: [“type”],“message”: “Invalid input: expected “tool-input-error””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolCallId”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolName”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“errorText”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“tool-output-available”],“path”: [“type”],“message”: “Invalid input: expected “tool-output-available””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolCallId”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“tool-output-error”],“path”: [“type”],“message”: “Invalid input: expected “tool-output-error””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“toolCallId”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“errorText”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“reasoning-start”],“path”: [“type”],“message”: “Invalid input: expected “reasoning-start””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“id”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“reasoning-delta”],“path”: [“type”],“message”: “Invalid input: expected “reasoning-delta””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“id”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“delta”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“reasoning-end”],“path”: [“type”],“message”: “Invalid input: expected “reasoning-end””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“id”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“source-url”],“path”: [“type”],“message”: “Invalid input: expected “source-url””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“sourceId”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“url”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}],[{“code”: “invalid_value”,“values”: [“source-document”],“path”: [“type”],“message”: “Invalid input: expected “source-document””},{“expected”: “string”,“code”: “invalid_type”,“path”: [“sourceId”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“mediaType”],“message”: “Invalid input: expected string, received undefined”},{“expected”: “string”,“code”: “invalid_type”,“path”: [“title”],“message”: “Invalid input: expected string, received undefined”},{“code”: “unrecognized_keys”,“keys”: [“finishReason”],“path”: ,“message”: “Unrecognized key: “finishReason””}…
This is too long to fit inside a single message.
Here is the network output from the event stream:

Edit: sorry for the formatting, the error is very very long