The aggregation phenomenon is very common in numerous activities of social insects, however, it is often their functional aspects that are studied, leaving their mechanisms not so well understood. With the example of chain formation in Œcophylla longinoda, we present the mechanisms responsible for these collective structures. Our experimental results show that a change in the probability that a worker will decide to join or leave a chain is (1) strongly dependent on the number of ants present in the chain and (2) slightly dependent on the presence of a visual stimulus. The determining role of these probabilities is validated with the use of a mathematical model that reproduces the formation and breakup of the chain. Moreover, it predicts other properties of aggregation such as the influence of nest population size.