Multi-agent cooperation through in-context co-player inference

Marissa A. Weis, Maciej Wołczyk, Rajai Nasser, Rif A. Saurous, Blaise Agüera y Arcas, João Sacramento, Alexander Meulemans

Abstract

Achieving cooperation among self-interested agents remains a fundamental challenge in multi-agent reinforcement learning. Recent work showed that mutual cooperation can be induced between "learning-aware" agents that account for and shape the learning dynamics of their co-players. However, existing approaches typically rely on hardcoded, often inconsistent, assumptions about co-player learning rules or enforce a strict separation between "naive learners" updating on fast timescales and "meta-learners" observing these updates. Here, we demonstrate that the in-context learning capabilities of sequence models allow for co-player learning awareness without requiring hardcoded assumptions or explicit timescale separation. We show that training sequence model agents against a diverse distribution of co-players naturally induces in-context best-response strategies, effectively functioning as learning algorithms on the fast intra-episode timescale. We find that the cooperative mechanism identified in prior work—where vulnerability to extortion drives mutual shaping—emerges naturally in this setting: in-context adaptation renders agents vulnerable to extortion, and the resulting mutual pressure to shape the opponent's in-context learning dynamics resolves into the learning of cooperative behavior. Our results suggest that standard decentralized reinforcement learning on sequence models combined with co-player diversity provides a scalable path to learning cooperative behaviors.

Introduction

In Decentralized Multi-Agent Reinforcement Learning (MARL), getting self-interested agents to cooperate in mixed-motive games like the Iterated Prisoner’s Dilemma (IPD) is notoriously difficult. Independent optimization usually leads to mutual defection. While "learning-aware" agents can induce cooperation by shaping opponent dynamics, current methods often require complex, hardcoded assumptions or artificial timescale separations. This work explores whether standard sequence models can naturally learn to shape opponents through in-context learning when trained against a diverse pool of co-players.

Methods

The core hypothesis is that diversity in training environments forces agents to perform in-context inference, which inadvertently enables cooperative shaping.

Mixed Pool Training

Agents are trained in a "Mixed Pool" where they encounter a diverse set of opponents. Half of the interactions are against another learning agent, and the other half are against a "Tabular Agent" with a randomized, static strategy. Agents must infer the opponent's strategy from interaction history within a single episode (100 steps) without explicit identification.

Algorithms

Two decentralized RL algorithms were evaluated:

  1. Independent A2C: A standard model-free Advantage Actor-Critic algorithm.
  2. Predictive Policy Improvement (PPI): A novel model-based algorithm using a sequence model as both a world model and a policy prior.

Results

Both A2C and PPI agents successfully converged to high rates of mutual cooperation in the IPD when trained in the mixed pool.

PPI training progress and ablations showing that cooperation emerges only when in-context inference is required.

The Role of In-Context Inference

Ablation studies confirmed that the need for inference is critical for cooperation. When agents were trained without a diverse pool ("No Tabular Opp.") or given explicit opponent identification ("Opponent ID"), they failed to cooperate and collapsed to mutual defection.

A2C training progress and ablations, mirroring the findings that diversity and the need for inference drive cooperation.

The Causal Chain of Cooperation

The results suggest a three-step mechanism:

  1. Diversity forces in-context learning: Agents must identify and adapt to strategies on the fly.
  2. Adaptation creates vulnerability: Rapid in-context adaptation makes agents act like "naive learners," vulnerable to extortion.
  3. Mutual extortion breeds cooperation: Mutual pressure to shape each other's in-context learning pushes agents toward cooperative equilibria.

Discussion

This research demonstrates that in-context learning in sequence models can replace explicit meta-learning architectures for achieving multi-agent cooperation. While tested on the IPD, the findings have significant implications for Large Language Models (LLMs). Since LLMs naturally exhibit strong in-context learning from diverse data, standard decentralized RL could be a scalable path for inducing cooperative social behaviors in interacting AI agents.

Summary updated

BibTeX
@misc{weis2026multi,
  author = {Marissa A. Weis and Maciej Wołczyk and Rajai Nasser and Rif A. Saurous and Blaise Agüera y Arcas and João Sacramento and Alexander Meulemans},
  title = {{Multi-agent cooperation through in-context co-player inference}},
  year = {2026},
  eprint = {2602.16301},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2602.16301},
}
Figure