Scientists have known for decades that what we eat can change the balance of microbes in our digestive tracts. Choosing between a BLT sandwich or a yogurt parfait for lunch can increase the populations of some types of bacteria and diminish others—and as their relative numbers change, they secrete different substances, activate different genes and absorb different nutrients.

And those food choices are probably a two-way street. Gut microbes have also been shown to influence diet and behavior as well as anxiety, depression, hypertension and a variety of other conditions. But exactly how these trillions of tiny guests—collectively called the microbiome—influence our decisions on which foods to stuff into our mouths has been a mystery.

Now neuroscientists have found that specific types of gut flora help a host animal detect which nutrients are missing in food and then finely titrate how much of those nutrients the host really needs to eat. “What the bacteria do for appetite is kind of like optimizing how long a car can run without needing to add more petrol to the tank,” says senior author Carlos Ribeiro, who studies the eating behaviors of Drosophila melanogaster, a type of fruit fly, at Champalimaud Center for the Unknown in Lisbon.

In a paper published recently in PLOS Biology, Ribeiro and his team demonstrated how the microbiome influences drosophila’s nutritional decisions. First, they fed one group of flies a sucrose solution containing all the necessary amino acids. Another group got a mix that had some of the amino acids needed to make protein but lacked essential amino acids that the host cannot synthesize by itself. For a third group of flies, the scientists removed essential amino acids from the food one by one to determine which was being detected by the microbiome.

After 72 hours on the various diets, flies in the all three groups were presented with a buffet offering their usual sugary solution alongside protein-rich yeast. The researchers found that flies in the two groups whose diet lacked any single essential amino acid got a strong craving for yeast to make up for the missing nutrients. But when scientists increased five different types of bacteria found in the flies’ digestive tracts—Lactobacillus plantarum, L. brevis, Acetobacter pomorum, Commensalibacter intestini and Enterococcus faecalis—the flies completely lost the urge to eat more protein.

The researchers found that the flies’ amino acid levels were still low, indicating the bacteria were not simply replacing nutrients missing from the flies’ diet by producing the amino acids themselves. Instead the microbes were functioning as little metabolic factories, transforming the food they got into new chemicals: metabolites that the researchers believe might be telling the host animal it could carry on without the amino acids. As a result of this microbial trick, the flies were able to continue reproducing, for example—even though an amino acid deficiency usually hampers cell growth and regeneration and therefore reproduction, Ribeiro explains.

Two kinds of bacteria were particularly effective in influencing the appetites of flies this way: Acetobacter and Lactobacillus. Increasing both was enough to suppress the flies’ protein cravings and increase their appetite for sugar. These two bacteria also restored the flies’ reproductive abilities, indicating their bodies were carrying out normal functions that typically get restricted when there is a nutritional deficiency. “How the brain handles this trade-off of nutritional information is very fascinating, and our study shows that the microbiome plays a key role in telling the animal what to do,” Ribeiro says.

Next the team removed an enzyme needed to process the amino acid tyrosine in flies, making it necessary for the flies to get tyrosine via their food, just like other essential amino acids. Surprisingly, they found that Acetobacter and Lactobacillus were unable to suppress the craving for tyrosine in the modified flies. “This shows that the gut microbiome has evolved to titrate only the normal essential amino acid intake,” Ribeiro explains.

The research adds a new perspective on coevolution of microbes and their hosts. “The findings show there is a unique pathway that has coevolved between animals and the resident bacteria in their gut, and there is a bottom-up communication about diet,” says Jane Foster, who is a neuroscientist at McMaster University in Ontario and not associated with the study.

Although the research does not specify the exact mechanism of communication, Ribeiro thinks it could take different forms. Strong evidence from the study indicates that microbially derived metabolites carry information from the gut to the brain, telling the host whether it needs a particular kind of food. “One of the big evolutionary mysteries is why we lost the ability to produce essential amino acids,” he says. “Maybe these metabolites gave animals more leeway to be independent of these nutrients and to deal without them sometimes.”

Microbes may have their own evolutionary reasons for communicating with the brain, he adds. For one thing, they feed on whatever the host animal eats. For another, they need host animals to be social so the guests can spread through the population. The data are limited to animal models so far, but Ribeiro believes that gut-brain communication can provide fertile ground for developing treatments for humans in the future. “It’s an interesting therapeutic window that could be utilized to improve behaviors related to diet one day,” he says.