Grouping is an evolutionary strategy that allows individuals to optimize foraging success in habitats of varying quality and when under the risk of predation, but group foraging can lead to competition between group members. The effects of group size, habitat, predation, and competition on foraging success also can change as animals grow. Our study explored how these concurrent factors influenced the foraging success of group members at two different life stages. In a wild population of coho salmon (Oncorhynchus kisutch), we first tested four hypotheses concerning the effects of group size on foraging success. We then analyzed our field observations with structural equation modeling to test causal relationships between group size, habitat, predation risk, competition, and the foraging success of individuals during two periods of development. We found support for the hypothesis that the relationship between group size and foraging success was parabolic during both study periods, revealing an optimal range of group sizes that maximized individual foraging success, which was conserved as fish aged. Predation risk had a positive effect on group size, particularly for older fish, and distance to cover and water depth were indicators of risk for both age groups. As group size increased, so did competition, but only for young fish; competition only had a weak positive effect on foraging success for older fish. Our results reveal that the relative direct effects of predation risk and competition on foraging success were weak compared with the direct effect of group size. Our study provides new insights and theoretical implications for understanding how selective forces-that is, group size, predation risk, competition, habitat, and ontogeny-act concurrently to affect foraging success in wild populations.