the species included in our study had similarly sized guards and foragers (Fig. 1a). The analysis further suggests that increased guard size evolved five times independently among the 28 study species (Fig. 1a). All transitions towards increased guard size have occurred relatively recently, during the last 2025 million years (Fig. 1a). This period coincides with the period of diversification of the cleptoparasitic genus Lestrimelitta from non-parasitic ancestors (Fig. 1a). According to a recent survey, 10 of the 28 studied species are known targets of Lestrimelitta, whose attacks frequently destroy colonies29. Targets of robber bees are about four times more likely to have larger guards (70% or 7 of 10 species) than non-target species (16.7% or 3 of 18). We again used Pagel's method24 to test for a correlated evolution of binary characters and found that species are significantly more likely to have guards of increased size if they are victims of Lestrimelitta robber bees (likelihood ratio = 8.17, P = 0.017).DiscussionOur results show that task-related worker differentiation is relatively common in stingless bees, with 10 of the 28 tested species having entrance guards that are significantly larger than the foragers of the same colonies. The three species with the most pronounced size differentiation, T. angustula, T. fiebrigi, and F. longipes show a bimodal size distribution (Fig. 1b, c; Supplementary Fig. 1), which indicates that guards and foragers represent distinct minor and major (soldier) sub-castes6,12. In the other seven species with worker size differentiation, guard and forager sizes, although significantly different, show considerable overlap. This size overlap among worker groups performing different tasks is similar to some bumble bee species, where body size is linked to task performance, but workers performing different tasks come from the same size distribution30. These findings show that the extent of worker differentiation in stingless bees varies among species, from guards of slightly increased size to distinct soldiers.We discovered that in several Frieseomelitta species, guards are not only larger but also constitute a distinct color morph (Fig. 1d, f, g; Supplementary Fig. 2a). Guards are significantly darker than foragers, indicating stronger sclerotization, but measurements of cuticle thickness in the clypeal area did not show differences between guards and foragers. It is possible that camouflage explains color differences as the darker color makes entrance guards less conspicuous when they defend the nest entrance (Supplementary Fig. 2b). Increased melanization can also increase resistance to pathogens and physical damage31, which might be particularly beneficial for individuals that are more likely to encounter these risks. In some stingless bees and the honey bee (Apis mellifera), guarding tasks precede foraging activities14,15,17 and it is possible that Frieseomelitta guards change melanization after some days to become yellow foragers. However, behavioral observations in F. varia showed that workers performing defensive tasks (guarding and fighting) were of similar age (40.0 5.1 days) to foragers (37.2 9.2 days)32. This mirrors the situation found in T. angustula, where soldiers and foragers are of the same age17 and suggests that guarding and foraging are not sequential tasks inFrieseomelitta, but that the larger, dark guards represent a distinct soldier caste.Allometry