Brands love when social media stars take to Instagram or TikTok to advertise their soap, probiotic sodas, makeup and more. But many of those same brands are eager to avoid influencers who discuss politics.

Making sure the two don’t mix has become a fraught exercise in the growing, and often unpredictable, influencer industry. How can a brand join the conversation while making sure it doesn’t get too deep?

With the presidential election looming, some marketing agencies have started to pitch advertisers on new tools that grade the so-called brand safety of social media personalities. Some of the tools even use artificial intelligence to predict the likelihood that a particular influencer will discuss politics in the future.

A tool recently introduced by Captiv8, a marketing firm that helps advertisers like Walmart and Kraft Heinz connect with influencers, uses artificial intelligence to analyze mentions of social media stars in online articles, and then determines whether they are likely to discuss elections or “political hot topics.” The firm also assigns letter grades to creators based on their posts, comments and media coverage, where an “A” means very safe and a “C” signals caution. The grades incorporate categories like “sensitive social issues,” death and war, hate speech or explicit content.

Viral Nation, another influencer agency, also offers marketers a product that makes “risk profiles” for creators. The tool, which the company has been using for more than year, assesses years of posts — including hours of dialogue from videos — and can detect whether people are holding weapons or protest signs in their content, even if those elements aren’t mentioned in captions or audio.