Code-Space Response Oracles: Generating Interpretable Multi-Agent Policies with Large Language Models

Daniel Hennes, Zun Li, John Schultz, Marc LanctotarXiv 2026

TL;DR

Code-Space Response Oracles (CSRO) reframes multi-agent policy discovery by replacing traditional "black-box" deep reinforcement learning oracles with Large Language Models that output human-readable, executable code. By treating best-response optimization as a program synthesis task, CSRO delivers highly interpretable, verifiable strategies that perform competitively with mature baselines while dramatically improving sample efficiency.

What Problem Does This Paper Address?

In multi-agent reinforcement learning (MARL), algorithms like Policy-Space Response Oracles (PSRO) are highly effective at finding approximate game-theoretic equilibria in complex environments. PSRO works iteratively: it computes a "best response" policy against a mix of existing opponent strategies, adds this new policy to the pool, and repeats.

However, standard implementations rely on deep reinforcement learning (RL) oracles to approximate these best responses. This introduces two major challenges:

  1. Opaque "Black Boxes": The resulting policies are deep neural networks whose weights offer no insight into why a specific action was taken. This lack of interpretability makes strategy verification and debugging nearly impossible, presenting a massive barrier for deployment in high-stakes, real-world applications.
  2. Sample Inefficiency: Training these deep RL oracles typically requires millions or billions of environment simulations to converge.

Methods

CSRO addresses these limitations by replacing the deep RL oracle with an LLM (specifically Gemini 2.5 Pro) that synthesizes policies directly as executable Python code.

The core algorithm follows the iterative structure of PSRO but introduces two novel scaling and refinement mechanisms:

  • Cross-Iteration Strategic Adaptation: At each iteration, the LLM is prompted with the game rules, an API specification, and context about the opponent's current meta-strategy. To prevent the prompt from exceeding context limits in complex games, CSRO introduces context abstraction—either summarizing opponent strategies in natural language or filtering them down to the "Top 5" most impactful opponents.
  • Intra-Iteration Policy Refinement: To ensure the generated code is a robust best response, the authors evaluate three inner feedback loops:
  • ZeroShot: The LLM generates the code in a single pass.
  • LinearRefinement: A single-threaded loop where a generated policy is evaluated; if it loses, the LLM receives the feedback and iteratively regenerates the code until it achieves a non-negative utility or hits a budget limit.
  • AlphaEvolve: A large-scale distributed evolutionary system that mutates code across multiple threads, using game performance as the fitness score to guide the search.
Example run of CSRO in Repeated Rock-Paper-Scissors

Datasets

The framework was evaluated using OpenSpiel on two classic analytical game environments:

  1. Repeated Rock-Paper-Scissors (RRPS): Played over 1,000 consecutive rounds. Performance was benchmarked against a diverse evaluation population of 43 hand-coded, heuristic bots from international programming competitions.
  2. Repeated Leduc Hold’em Poker: Played over 100 rounds. This environment introduces imperfect information, private/public cards, and multiple betting rounds, requiring stateful reasoning like bluffing and value betting. It was evaluated against CFR+, AlwaysCall, and AlwaysFold.

Key Insights and Ideas

  • Opponent Conditioning is Mandatory: Ablation studies (ZeroShot with no opponent input) revealed that providing information about opponent strategies is the single most critical component of the prompt. Without it, the generated policies suffer from extreme exploitability.
  • The Code vs. Text Trade-off: In zero-shot settings, providing natural language descriptions of opponent strategies yields better results than providing raw source code, likely because text summaries reduce prompt complexity. However, when paired with iterative refinement loops, providing raw source code performs significantly better.
  • Diversity Prevents Overfitting: When filtering opponent context, selecting the "Top 5" opponents outperforms filtering by minimum probability support. The "Top 5" filter ensures a diverse set of strategies remains in the prompt, preventing the LLM from overfitting to a single dominant counter-strategy.
  • Linear Computational Scaling: Unlike standard LLM game agents that must be queried on every single turn (e.g., 1,000 API calls per game), CSRO generates a complete, reusable code policy once per training iteration. This makes it highly efficient, as API calls scale linearly with training iterations rather than game steps.

Key Results

  • Competitive Performance: In RRPS, LinearRefinement (code) with Top 5 filtering achieved an aggregate score of 122.1, performing competitively with a 27B parameter Gemma 3 baseline (126.0) and vastly outperforming the deep RL baseline (PSRO-IMPALA at -532.1).
  • Game-Theoretic Near-Optimality: In Leduc Poker, CSRO-AlphaEvolve achieved an exploitability of just 4.4 ± 0.6 and an aggregate score of 44.9 ± 4.1, outperforming the game-theoretic solver baseline CFR+ (39.8 ± 0.3).
Performance of CSRO variants in Repeated Rock-Paper-Scissors
  • Algorithmic Sophistication: Qualitative analysis of the generated code proved that the LLM did not just retrieve simple patterns. For RRPS, it synthesized a highly sophisticated ensemble agent featuring 32 parallel predictors, non-linear vote weighting, and an explicit second-order "Theory of Mind" model to simulate how the opponent was modeling it. For poker, it successfully coded dynamic Expected Value (EV) calculations to execute value betting and passivity exploitation.

Limitations and Future Work

  • LLM Dependency: CSRO is inherently tied to the code-generation capabilities of the underlying LLM. Poor prompts or weaker models can result in syntactically incorrect code, requiring additional error-handling and regeneration logic.
  • Upfront API Costs: While sample-efficient in terms of environment steps, the framework introduces significant computational costs during the intra-iteration refinement and evolutionary search phases due to repeated LLM API calls.
  • High-Dimensional Scaling: Scaling CSRO to environments with massive, high-dimensional observation spaces (such as StarCraft or Stratego) remains an open challenge. Representing complex visual states and extensive strategic histories within the context window limits of current LLMs is a major engineering hurdle.

Summary updated

BibTeX
@misc{hennes2026code,
  author = {Daniel Hennes and Zun Li and John Schultz and Marc Lanctot},
  title = {{Code-Space Response Oracles: Generating Interpretable Multi-Agent Policies with Large Language Models}},
  year = {2026},
  eprint = {2603.10098},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.10098},
}
Figure