Social and ecological conditions can influence flock formation (e.g. number of flocks, flock size, etc.) depending on the degree of social attraction of a species. We studied group formation in brown-headed cowbirds (Molothrus ater) over short time periods (30 min) in two semi-natural experiments conducted under controlled conditions. First, we determined the shape of the relationship between intake rate and flock size by manipulating group size in a single enclosure. Second, we assessed the role of population size, food abundance, and predation risk, and their interactions, in flock size formation in a system of four enclosures (two with and two without food) connected to a central refuge patch. In the first experiment, we found that pecking rates peaked at intermediate flock sizes (three to six individuals), which was influenced by greater availability of foraging time and more aggressive interactions in large groups. In the second experiment, flock sizes in the patches with food increased with population size likely due to the benefits of patch exploitation in groups. Flock size decreased after predator attack probably because refuge availability reduced perceived predation risk more than flocking in larger groups. Food abundance had minor effects, varying flock sizes between the two patches with food, under high food availability conditions when population size was high, probably due to social cohesion effects. Our results suggest that: (1) this species has an inverted-U food intake–group size relationship with a range of intake-maximizing flock sizes rather than a single peak, (2) the presence of a near refuge modifies the expected benefits of group patch exploitation under high predation risk, and (3) an increase in population size would more likely be translated into rapid increases in the size of the flocks rather than in more new flocks.