After half a year in development, Spam protection in Android Messages is finally going live to some users, though not everyone seems to have it just yet. This means the change appears to be server-side and in a limited rollout for the time being. When the feature does hit your device, you should see a notification detailing you about the new Spam protection.
A new “Spam protection” option in the Advanced section of the Settings menu will also appear allowing you to manually toggle the feature on or off. When the setting is enabled, some information about the Android messages you receive will be sent to Google, however, it will not read the message content like your phone number or the actual message itself.
How the Spam protection works is undescribed, but presumably, it looks at that data statistically to determine commonalities between spam messages to detect them. If you send a spam report manually, it still submits the full message to Google, including phone numbers of both sender and recipient as well as the message’s contents. For now, it remains to be seen how effective Google’s solution may be against the increasing number of spam messages.