Studies on nonsocial insects have elucidated the regulatory strategies employed to meet nutritional demands [1-3]. However, how social insects maintain the supply of an appropriate balance of nutrients at both a collective and an individual level remains unknown. Sociality complicates nutritional regulatory strategies [4-6]. First, the food entering a colony is collected by a small number of workers, which need to adjust their harvesting strategy to the demands for nutrients among individuals within the colony [4-7]. Second, because carbohydrates are used by the workers and proteins consumed by the larvae [7-14], nutritional feedbacks emanating from both must exist and be integrated to determine food exploitation by foragers [4-6, 15, 16]. Here, we show that foraging ants can solve nutritional challenges for the colony by making intricate adjustments to their feeding behavior and nutrient processing, acting both as a collective mouth and gut. The amount and balance of nutrients collected and the precision of regulation depend on the presence of larvae in the colony. Ants improved the macronutrient balance of collected foods by extracting carbohydrates and ejecting proteins. Nevertheless, processing excess protein shortened life span--an effect that was greatly ameliorated in the presence of larvae.