So that's a huge part of the game, try to detect toxicity early and widen your spread as much as needed to stay out of it. In practice it means that whenever toxic flow hits a book the book's spread (the distance between the bid and ask) will widen as well as the new price is sought.
Pay for Order Flow is a big tool here because you pretty much know that all trades done on free brokers are non-informed. If you subtract that out you increase the signal-to-noise ratio on predicting toxic flow.
Finally, lets say you are hit and take on a bunch of toxic inventory. Now you need a place to dump it to. Your options depend heavily on your situation, but you might either hope you have complementary non-MM strategies which can absorb this inventory or you might hope that you can quickly shovel it off to another venue (another exchange, a dark pool) where you won't get hurt so badly.
And if you can't do any of that, you take a loss.