An AI agent that must cooperate with a teammate it has never met, such as a human or a separately trained bot, usually fails in a specific way. During training it settles into private habits that only its training partners understand. Large language models (LLMs) avoid part of this problem because they already carry human conventions. The price is that they reason token by token at every game step, which is too slow for real-time play. A different option has recently appeared: the LLM writes an executable Python policy between episodes, reads feedback, and rewrites the policy, and that policy then runs at simulator speed. So far, though, the feedback in these loops has come from the program playing with copies of itself. We expect this to recreate the private-habits problem, only now in code instead of neural weights.
The proposal has one central change. We refine the policy program using structured feedback from cross-play, meaning episodes against a pool of diverse training partners. We then score the final program only against partners held out from that pool, including human proxies. Our claim is that the source of the refinement signal decides whether code policies generalize to new teammates. Self-play refinement should produce programs that score well with themselves and collapse with strangers. Cross-play refinement should produce programs with explicit logic for inferring what the partner intends, and those programs should hold up. A second, smaller question follows. If an open-weight model is fine-tuned on these refinement traces, mixed with general instruction data, does it learn to run the loop itself? And does the debugging habit carry over to code-reasoning benchmarks?
Where this sits relative to prior work
The closest work is Beyond Scalar Rewards: Dense Feedback for LLM Policy Synthesis in Sequential Social Dilemmas. It has frontier LLMs iteratively write and refine Python policies for the multi-agent games Gathering and Cleanup, using multi-dimensional social metrics as feedback. That paper supplies our method: an inter-episode code loop with rich diagnostics instead of a single reward number. It evaluates only self-play and homogeneous populations. It never tests against unseen partners, and it reports that programs sometimes cheat by mutating simulator memory. We keep the loop and change two things: who the program plays with while it is refined, and what it is judged against.
Two further papers show that programs help with coordination. KnowPC searches a hand-built domain-specific language with a genetic algorithm. It reports that the resulting programs keep their performance when the kitchen layout changes and train in about 0.1 hours, against up to 36 hours for the population method COLE. It uses no LLM, and its language cannot express open-ended partner models. Empowering Large Language Model Agents through Action Learning shows that single-agent LLMs prefer to repair Python functions over writing text notes (90% of the time) and gain 72.2% vs 54.7% success on AlfWorld. Both results motivate using code as the policy format. Neither involves a partner.
ProAgent coordinates in Overcooked-AI with a frozen LLM that reasons about teammate intentions at run time. It reports gains of over 10% against human proxies relative to COLE. It also names inference latency as its main limitation, and our design is meant to remove that cost.
The evaluation literature sets constraints on how we measure success. OvercookedV2 shows that the original Overcooked mixes up coordination failure with failure on unfamiliar board states. It gives a case where self-play scores near 145 but cross-play scores fall to -81. ZSC-Eval shows that methods which work with moderate partners break down with expert ones, and it provides a diverse partner pool together with a Best-Response Proximity metric. We therefore separate refinement partners from evaluation partners throughout.
For the fine-tuning stage, Sparks of Cooperative Reasoning trains a 4B model on Hanabi text moves and reports transfer to AIME 2025 and EventQA. Its training signal is moves, not programs, which makes it the natural contrast. Demystifying Instruction Mixing and AgentBank show that mixing general and code data with specialist data prevents forgetting. AgentBank also warns that embodied interaction data can transfer negatively, so we treat data mixing as a constraint to control rather than as a contribution.
Research Program
The system has three parts. The first is a sandboxed policy interface. The program receives a read-only copy of the observation and returns a legal action, and has no access to simulator objects, which closes the exploit reported in the Dense Feedback paper.
The second part is a partner pool split into two sets. The refinement partners are the training population for Overcooked from ZSC-Eval, and for Hanabi they are behavior-cloned policies trained on the 3,079-game open participant set of the Ad-Hoc Human-AI Coordination Challenge. The evaluation partners are the held-out ZSC-Eval partners, the Overcooked-AI human-proxy models, and the AH2AC2 gold human proxies. None of these evaluation partners is ever seen during refinement.
The third part is a feedback compiler. It converts cross-play logs into short, partner-specific diagnostics. In Overcooked these include waits caused by the partner, collisions, two agents claiming the same subtask, and orders that were dropped. In Hanabi they include plays that followed a hint the program misread, and violations of the Good Touch convention, which the proxies follow on 88% of moves. The compiler reports these per partner, so the LLM sees where its assumptions about teammates fail, not just a lower average score.
A frontier LLM runs the loop for a fixed number of rounds. We keep a rollback rule: a revision is accepted only if it improves the worst-case score across the refinement partners, not only the average. Averages can hide a new failure against one partner type, and the worst-case rule also guards against the plateaus and error amplification seen in iterative debugging. At deployment the final program runs with no LLM calls.
In the second stage we fine-tune an open 7B model on the accepted refinement traces. Each trace contains a program, its diagnostics, and the revision that followed. We mix these traces with general chat and code instructions. The starting ratio follows the roughly 1.5x specialist-to-general ratio reported in Demystifying Instruction Mixing, and we sweep around it. We then ask whether the small model can run the loop itself, and whether it improves on code-reasoning benchmarks.
Baselines
The naive reference point is the LLM's first program with no refinement at all. It measures how much conventional knowledge the model brings before any feedback.
The ablation that isolates our key ingredient is self-play refinement. It uses the same loop, prompts, LLM, number of rounds, and feedback compiler, but the diagnostics come from the program paired with copies of itself, following the Dense Feedback approach. We run both conditions with identical LLM-call and environment-step budgets. Our claim holds only if cross-play refinement beats self-play refinement on held-out partners while the two remain comparable in self-play. For context, the Dense Feedback paper reports a 54% efficiency gain in Cleanup from dense over scalar feedback. That number concerns self-play in a different environment, so it motivates this baseline rather than serving as a target.
The second control addresses whether refinement adds anything beyond search. It samples many independent programs with the same total call budget and keeps the one with the best worst-case cross-play score. If this matches iterative refinement, then partner-diverse selection is what matters and the iteration is not.
The strongest program-synthesis competitor is KnowPC. We run it with its published language and search on the Overcooked-AI layouts and on layout-shifted variants, give it the same refinement partners, and match wall-clock training time. KnowPC reports a coordination reward on shifted layouts nearly double that of the best deep RL methods.
The strongest LLM-at-run-time competitor is ProAgent with the same underlying LLM. We report reward alongside per-step latency. The file gives no absolute Overcooked scores for ProAgent, only the over-10% gain over COLE, so we reproduce it ourselves.
For Overcooked, the population-trained reinforcement learning methods FCP, MEP, and COLE come from the ZSC-Eval toolkit. For Hanabi, the reference points are the AH2AC2 leaderboard figures: Off-Belief Learning scores a mean of 21.04/25 in two-player games, and HDR-IPPO scores 14.03/25 in three-player games. Beating HDR-IPPO in three-player games while approaching Off-Belief Learning in two-player games, using a program with no neural policy, would be a strong result. Sparks of Cooperative Reasoning adds context: the best prompted LLMs reach about 15/25 in Hanabi.
For the fine-tuning stage, the main baseline is the same 7B model trained on Sparks-style text-move trajectories, matched in token count and data mix, alongside a model trained on general data only.
Why not just…?
Why not just prompt a frontier reasoning model at every step? Sparks reports that even o3-class models reach only about 15/25 in Hanabi, below human experts at over 20/25. The same paper reports a drop of about 2.7 points when the model must keep its own deductions in working memory across turns. ProAgent identifies latency as its main barrier. We run this baseline anyway. If it matches us on held-out partners, our remaining advantage is latency, and we will report it as exactly that.
Why not just use KnowPC's genetic search, which is already fast and robust to layout changes? This is a real threat on the original Overcooked layouts, and we may not beat it there. Our bet is on OvercookedV2's partial-observability and asymmetric-information layouts, and on Hanabi. Coordinating in those settings requires tracking beliefs about the partner and reacting to signals, which a fixed rule language struggles to express. If KnowPC matches us on OvercookedV2 as well, the LLM contributes nothing beyond convenience, and we would say so.
Why not just refine in self-play and add partner diversity afterward, or train population reinforcement learning methods instead? OvercookedV2 and ZSC-Eval both show that population methods collapse with unfamiliar or expert partners. The self-play refinement ablation described above tests directly whether the source of the feedback matters.
Why not just sample many programs and keep the best one? This could plausibly work as well as refinement, which is why it is a full baseline with a matched budget. If it wins, we will reframe the contribution as partner-diverse program selection rather than refinement.
Proposed Experiments
We will run the experiments on the five Overcooked-AI layouts with human proxies, the ZSC-Eval layouts and partner pool, the OvercookedV2 partial-observability layouts, and AH2AC2 two-player and three-player Hanabi. The metrics are mean reward with held-out partners, the gap between self-play and cross-play scores, Best-Response Proximity, rate of rule-violating actions, and per-step latency.
The decisive check is whether cross-play refinement reduces the self-play/cross-play gap relative to self-play refinement at an equal budget, across at least three LLM random seeds. If the gap does not shrink, the central claim fails.
The secondary study compares the fine-tuned 7B models on two things. The first is their ability to run the refinement loop without the frontier model. The second is transfer to CRUXEval, HumanEval, and BBH, benchmarks used in Satori and CPL, plus AIME and EventQA as used in Sparks. We compare against the text-move model to test whether debugging coordination code teaches more general reasoning than playing moves does. We sweep the mix ratio to detect forgetting on general instruction following. A null transfer result here would still leave the main coordination result intact.
References
- Beyond Scalar Rewards: Dense Feedback for LLM Policy Synthesis in Sequential Social Dilemmas
- KnowPC: Knowledge-Driven Programmatic Reinforcement Learning for Zero-shot Coordination
- Empowering Large Language Model Agents through Action Learning
- ProAgent: Building Proactive Cooperative Agents with Large Language Models
- OvercookedV2: Rethinking Overcooked for Zero-Shot Coordination
- ZSC-Eval: An Evaluation Toolkit and Benchmark for Multi-agent Zero-shot Coordination
- Sparks of Cooperative Reasoning: LLMs as Strategic Hanabi Agents
- Demystifying Instruction Mixing for Fine-tuning Large Language Models
- AgentBank: Towards Generalized LLM Agents via Fine-Tuning on 50000+ Interaction Trajectories
- Ad-Hoc Human-AI Coordination Challenge
- Satori: Reinforcement Learning with Chain-of-Action-Thought Enhances LLM Reasoning via Autoregressive Search
- CPL: Critical Plan Step Learning Boosts LLM Generalization in Reasoning Tasks