You and I have bacteria living on the food in our intestine that play a vital role in regulating our hormones and our moods, not just digestion.
Carpenter ants have bacteria that have actually moved inside the cells of the intestinal lining and integrated themselves into the cellular metabolism. The symbiosis has become so close that the bacteria actually moved in, and the ant’s own cells made a home for them.
There’s a whole set of adaptations that make this possible. When a carpenter ant starts life as a fertilized egg, the single egg cell doesn’t divide, but instead just the nucleus divides. Again and again, until there is a giant cell with hundreds of cell nuclei. Of course, all this while, the digestive bacteria are also reproducing within this giant cell. When the cell is finally ready to divide itself up, one nucleus per cell, the bacteria shift almost all to one end, and that cell that breaks off with the greatest number of bacteria is destined to become the intestine. Of course, a few bacteria are also sequestered into the cells that are destined to become the gonads, so they are already preparing to be passed on to the next ant generation, to seed their intestines.