The ability to interact effectively within social groups is essential to primate and human behavior. Yet understanding the neural processes that underlie the interactive behavior of groups or by which neurons solve the basic problem of coding for multiple agents has remained a challenge. By tracking the interindividual dynamics of groups of three interacting rhesus macaques, we discover detailed representations of the groups’ behavior by neurons in the dorsomedial prefrontal cortex, reflecting not only the other agents’ identities but also their specific interactions, social context, actions, and outcomes. We show how these cells collectively represent the interaction between specific group members and their reciprocation, retaliation, and past behaviors. We also show how they influence the animals’ own upcoming decisions and their ability to form beneficial agent-specific interactions. Together, these findings reveal prefrontal neurons that code for the agency identity of others and a cellular mechanism that could support the interactive behavior of social groups.