How do primates learn to communicate? An influential, but largely untested model proposes that primates go through a pruning process, guided by social learning, during which they increasingly restrict alarm calling from initially broad ranges of animals to a few dangerous predators. To test this model, we conducted an experiment with free-ranging sooty mangabeys, Cercocebus atys atys, in which we systematically exposed different age groups to models of dangerous vipers and nonvenomous colubrid snakes. We found that young juveniles perceived all snakes as dangerous and indiscriminately alarm called, although they had the longest response latencies. In contrast, adults showed antipredator behaviours faster to vipers than colubrids but never alarm called to the latter, unlike juveniles. Finally, all young and some older juveniles alternated their gaze between the snake models and other group members, suggesting they engaged in social referencing, that is, gazing at others to assess their reactions to external events. Our study provides a systematic, empirical demonstration that, in nonhuman primates, predator learning starts with overgeneralization, followed by subsequent refinement via social learning during the juvenile phase.