When Lagria beetles, a genus of fuzzy, brass-colored bugs that live on soy plants, lay eggs, they protect them with special juice. A set of glands by the mother’s reproductive organs smear the clutch with symbiotic bacteria. As the eggs grow, the beneficial bacteria produce chemicals that fight off mold and other harmful microbes, like a homebrewed antifungal cream.

When those babies hatch into larvae, they’ll carry the bacteria with them for the rest of their lives, and females will pass them along to their own eggs. But Lagria beetles go through metamorphosis: They’ll disappear into a pupa, and emerge with an entirely new body. So how do they hold onto their bacterial partners during the transformation? According to a study published this week in the journal Frontiers in Physiology, two species of Lagria larvae have developed “pockets” on their backs, which store bacteria through the ravages of metamorphosis.

Video courtesy LV Flórez, RS Janke, S Moog, B Weiss, M Kaltenpoth

Plenty of insects depend on microbes for defense, or even to regulate their behavior. And so they’ve repeatedly evolved tools for carrying those partners through life. “There are lots of unique structures [for carrying symbionts],” says Rebekka Janke, the study’s lead author, and a doctoral student in ecology at the Johannes Gutenberg University of Mainz in Germany. A species of predatory wasp, called a beewolf, inoculates its offspring with bacteria stored in its antennae. Leaf-rolling weevils tuck bacteria into a pouch on their belly. “But this is always in the adult stage,” says Janke. In other insects, larvae even stash their bacteria in the environment, and pick them up again later as adults. “But Lagria beetles don’t need shelter, or anywhere to store them. They always have them with them.”

[Related: Bees make more friends when they’re full of healthy gut bacteria]

“It’s a great example of how hosts innovate to support their microbial partners,” says Tobin Hammer, who researches symbioses at the University of California at Irvine and was not involved in the paper. “Symbionts like these can provide useful services to hosts, but they also tend to be fragile.”

Studying Lagria beetle bacteria, called Burkholderia, is particularly challenging, because researchers have been unable to grow the bacteria in the lab. “My supervisor tried to cultivate [the symbiont], I tried to cultivate it, and then two other students tried to cultivate it, and we have another Ph.D. who’s trying now,” Janke says. So instead, they placed microscopic, glowing beads in the pockets that they could watch throughout the life cycle of the insect.

When it’s time to go through metamorphosis, Lagria beetle larvae hide in leaf litter under soybean plants. For about six days, “they’re just laying around, and they’re still relatively whitish,” Janke says. “They don’t have a cocoon, it’s just a little squishy thing.” Inside, they’re growing legs, genitals, and wings. But as that transformation is happening, the pockets remain in place on the outside of the pupa, protecting the bacterial partners. When the adult beetles are fully shaped, the back of the pupa splits open, right along the line that carries the bacteria. “The beetles are then crawling out, and the symbionts are then transferred all over the body.”

Janke says it’s not clear how the bacteria, which have no obvious way of moving on their own, then end up colonizing the adult female’s glands. But the fact that the microbes are so immobile, and so challenging to rear anywhere but inside a beetle, suggests that while the beetles have shaped their body to carry bacteria, these tiny companions are growing to be wholly dependent on the habitat the beetle provides. “The authors’ experiment using latex beads shows how much the host is in charge of where the symbionts go, and when,” Hammer notes.

Other similar types of bacteria aren’t so specialized. Janke says the team has succeeded in cultivating a related strain that sometimes shows up in beetles, but is more commonly found as a pathogen in soybean plants themselves. And Janke says that it’s possible that adult beetles are also picking up some symbionts as they eat. “It would also be interesting to know whether the pockets come with ecological costs,” Hammer notes. “For example, in the wild, perhaps they can be hijacked by parasites or pathogens to further their own transmission.”

Perhaps that’s how the partnership evolved in the first place: After rubbing shoulders while eating soy plants, the beetles may have adopted a guard dog, while the bacteria got a ride from plant to plant. For all the lengths that an insect will go to protect its bacteria, Janke says, “how the symbiont benefits from the host is always a bit unclear.”