a, b, Diagram illustrating an automated social operant task and the experimental pipeline. c, f, A subject animal (right) can freely nose-poke the social port, which automatically triggers the opening of a retractable gate after a 3-s delay. The subject is then allowed to closely interact for 7 s with an unfamiliar juvenile animal (c) or with an empty social chamber (f). Poking the null port causes a 10-s time-out before the next trial starts (c, f). Gate opening and closure take 2 s to complete. d, g, Representative raster plots showing nose-pokes of social and null ports before (day 0) and after (day 7) training, with the presence (d) or absence (g) of target animals. e, h, Cumulative distribution of nose-pokes in social and null ports from examples shown in d and g, on days 0 and 7. i, Subject animals develop strong preference for social port (calculated as the difference in the percentage of nose-pokes between social and null ports) with the presence of target animals over a 10-day experiment (1 day of baseline session, 7 days of training sessions with target animals, and 2 days of post-training sessions without target animals). One-way repeated measures ANOVA with Bonferroni post-hoc correction (*P < 0.05, ***P < 0.001). j, Number of pokes of social and null ports with target animals across 10 days . Two-way repeated measures ANOVA with Bonferroni post-hoc correction (**P < 0.01, ***P < 0.001). k, Subject animals fail to develop a preference for empty social port without target animals over an 8-day experiment (1 day of baseline session and 7 days of training sessions with an empty social chamber). As the animals did not develop any preference for empty social port, no post-training session was performed. P = 0.1552, one-way repeated measures ANOVA. l, Number of pokes of null and empty social ports across 8 days. P = 0.1534, two-way repeated measures ANOVA. m-p, Subject animals display distinct behavioral characteristics on the first (day 1) and last (day 7) days of the training session—fractions of trials showing anticipatory behavior (m), duration of anticipatory behavior (n), duration of interactions with the target animal during the 7-sec interaction window (o), and latency to first social contact after the gate opens (in trials when the subject pokes social port) (p). Two-way repeated measures ANOVA with Bonferroni post-hoc correction (*P < 0.05, ***P < 0.001). In (i, j, m-p), n = 17 mice; in (k, l), n = 25 mice. (i-l) mean ± SEM; (m-p) boxplots: center = median, box = quartiles, whisker = 10–90 percentile. For detailed statistics information, see Supplementary Table 1.